我有这些Kendo单选按钮,他们只选择第一个单选按钮值 这是快照 Please check this picture 它总是得到第一个值来保存而不是其余的,即使它们被检查,我也试过make one true然后它只发送永久为真的值,即使我改变它也行不通。
这是单选按钮代码
<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>');
}
});
这是控制器。它总是得到第一个保存而不是剩下的值,即使它们被检查了。
public ActionResult UploadFiles(IEnumerable files, long id, string documentType="")
答案 0 :(得分:2)
@Html.RadioButton
生成一个组的单选按钮,可以通过其name
(而不是id
)进行访问。
所以你必须得到这样的价值:
function UrlDrop() {
var docType = $("input[name='docType']:checked").val();
return '@Url.Action("UploadFiles", "Vendor")?id=' + id + "&documentType=" + docType;
}
答案 1 :(得分:0)
@(Html.Kendo().RadioButton().Name("radiobutton_legal").Checked(true).HtmlAttributes(new { @name = "search_type" }).Label("Физлицо"))
@(Html.Kendo().RadioButton().Name("radiobutton_entity").Checked(false).HtmlAttributes(new { @name = "search_type" }).Label("Юрлицо"))
@(Html.Kendo().RadioButton().Name("radiobutton_cooperative").Checked(false).HtmlAttributes(new { @name = "search_type" }).Label("ЖСК"))
-----
function addAddressData() {
var search_type = 0;
if ($("#radiobutton_legal").prop('checked')) {
search_type = 1
} else if ($("#radiobutton_entity").prop('checked')) {
search_type = 2
}
else if ($("#radiobutton_cooperative").prop('checked')) {
search_type = 3
}
return {
keyword: $("#autocomplete_address").val(),
search_type: search_type
}
}