我有这些 Kendo 单选按钮,它们仅选择第一个单选按钮值 这是快照 Please check this picture 它总是获取第一个值来保存而不是其余的,即使它们被检查,我也尝试通过使一个为真,然后它只发送永久为真的值,即使我更改它也不起作用。
这是单选按钮代码
<td class="span2">
@Html.Label("lblType","Select Document Type")
</td>
<td>
@Html.RadioButton("docType", "SA")Service Agreement
<br />
@Html.RadioButton("docType", "W9")W9
<br />
@Html.RadioButton("docType", "COI")Certificate of Insurance
<br />
@Html.RadioButton("docType", "WC")Workers Comp
<br />
@Html.RadioButton("docType", "Other")Other
</td>
这是java脚本。 UrlDrop 是具有 url 的函数,我在没有该函数的情况下使用了它,但也不起作用。
function UrlDrop() {
return '@Url.Action("UploadFiles", "Vendor")?id=' + id + "&documentType=" + $("#docType").val(); //is(":checked"); //val();
}
//alert($("#docType").val());
$(function () {
$('#dropZone').filedrop({
url:UrlDrop ,//'@*@Url.Action("UploadFiles", "Vendor", new { id = TempData["VendorId"], docTypes= (("docType:checked"))})*@',
paramname: 'files',
maxFiles: 10,
dragOver: function () {
$('#dropZone').css('background', '#71b43b');
},
dragLeave: function () {
$('#dropZone').css('background', '#dbf0cb');
},
drop: function () {
$('#dropZone').css('background', '#dbf0cb');
},
afterAll: function () {
$('#dropZone').html('The file(s) have been uploaded successfully!');
var grid = $("#VendorAttachmentGrid").data("kendoGrid");
grid.dataSource.page(1);
grid.dataSource.read();
},
uploadFinished: function (i, file, response, time) {
$('#uploadResult').append('<li>' + file.name + '</li>');
}
});
这是 Controller 。它总是获取第一个值来保存而不是其余的,即使它们被检查。
public ActionResult UploadFiles(IEnumerable files, long id, string documentType="")
最佳答案
@Html.RadioButton
生成一组单选按钮,可以通过其名称
(而不是id
)。
所以你必须得到这样的值:
function UrlDrop() {
var docType = $("input[name='docType']:checked").val();
return '@Url.Action("UploadFiles", "Vendor")?id=' + id + "&documentType=" + docType;
}
关于javascript - 我有这些 Kendo 单选按钮,它们仅选择第一个单选按钮值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26061744/