gpt4 book ai didi

javascript - 将动态值传递给 valums 上传中的其他参数

转载 作者:搜寻专家 更新时间:2023-11-01 05:25:07 26 4
gpt4 key购买 nike

我在 asp.net mvc 3 中使用 valums 上传文件插件。我有两个下拉框和一个 ajax valums 上传文件按钮。我在 View 中有以下代码:

<link href="@Url.Content("~/Content/css/fileuploader.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Content/js/fileuploader.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.7.2.js")" type="text/javascript"></script>


@using (Html.BeginForm("Upload", "AjaxUpload", FormMethod.Post, new { name = "form1" }))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Upload Wav File</legend>
<div class="editor-label">
@Html.Label("Select Language")
</div>
<div>

@Html.DropDownList("Language1", (SelectList)ViewBag.lang)
</div>
<div class="editor-label">
@Html.Label("Select Category")
</div>


<div>
@Html.DropDownList("ParentCategoryID", ViewBag.ParentCategoryID as SelectList)
</div>

<div id="file-uploader">
<noscript>
<p>
Please enable JavaScript to use file uploader.</p>
</noscript>
</div>
</fieldset>
}


<script type="text/javascript">


var uploader = new qq.FileUploader
({
element: document.getElementById('file-uploader'),
params: {
param1: document.getElementById("Language1").value,
param2: document.getElementById("ParentCategoryID").value
},
action: '@Url.Action("upload")', // put here a path to your page to handle uploading
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'], // user this if you want to upload only pictures
sizeLimit: 4000000, // max size, about 4MB
minSizeLimit: 0, // min size
debug: true
});
</script>

问题:当我使用 document.getElementByID 传递 valums 上传函数的 params 属性中的值时,即使我选择其他选项,它也总是采用选择列表的第一个选项的值。我确信它在第一次加载页面时具有值(value),即 document.getElementById。如何获取当前选定的值并传递给上面代码中的 params 属性:

我有如下 Controller 操作:

[HttpPost]
public ActionResult Upload(HttpPostedFileBase qqfile, string param1, string param2)
{
..............
}

最佳答案

您可以在提交附加值时使用 setParams 方法。

var uploader = new qq.FileUploader({
onSubmit: function() {
uploader.setParams({
anotherParam: 'value'
});
}
});

关于javascript - 将动态值传递给 valums 上传中的其他参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11575587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com