2014-09-26 46 views
0

我有這些劍道單選按鈕,他們只選擇第一個單選按鈕值 這裏是扣 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>'); 
     } 
    }); 

這裏是控制器。它總是獲得第一個值,即使它們被檢查,也不會保存其餘的值。

public ActionResult UploadFiles(IEnumerable files, long id, string documentType="") 

回答

1

@Html.RadioButton產生的無線電按鈕的其可以通過訪問其name(而不是id)。

所以,你必須得到這樣的價值:

function UrlDrop() { 
    var docType = $("input[name='docType']:checked").val(); 
    return '@Url.Action("UploadFiles", "Vendor")?id=' + id + "&documentType=" + docType; 
} 
+0

感謝隊友非常感謝你 – 2014-09-26 14:51:24