I've这些剑道单选按钮,它们只选择第一个单选按钮值

I've these Kendo radio buttons and they select just the first radio button value

本文关键字:单选按钮 选择 第一个 ve      更新时间:2023-09-26

我有这些Kendo单选按钮,它们只选择第一个单选按钮值这是快照请检查此图片它总是得到第一个要保存的值,而不是其他值,即使它们被选中,我也尝试过使一个值为真,然后它只发送永久为真的值,即使我更改了它也不会起作用。

这是无线电按钮代码

<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="")

@Html.RadioButton生成一个单选按钮组,可由其name(而非id)访问。

所以你必须得到这样的值:

function UrlDrop() {
    var docType = $("input[name='docType']:checked").val();
    return '@Url.Action("UploadFiles", "Vendor")?id=' + id + "&documentType=" + docType;
}
@(Html.Kendo().RadioButton().Name("radiobutton_legal").Checked(true).HtmlAttributes(new { @name = "search_type" }).Label("Физлицо"))
                 &nbsp;&nbsp;
                 @(Html.Kendo().RadioButton().Name("radiobutton_entity").Checked(false).HtmlAttributes(new { @name = "search_type" }).Label("Юрлицо"))
                 &nbsp;&nbsp;
                 @(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
        }
    }