2015-08-14 75 views
-4

我有帶單選按鈕的表(每行一個)。 他們將從空缺開始。 一次只允許一個點擊。 如果我點擊一個填充的單選按鈕,它會清除它。我想在一個表中使用RadioButtons,其中只允許選擇一個

該應用使用MVC,Razor,jQuery,C#。

我應該使用jQuery與onclick或onload? 我應該使用剃刀嗎?與.RadioButtonFor或.RadioButton?

    <table id='id="rdBtnID1' cellpadding="3px" class="tableBorder" style="width: 90%" > 
         <tr style="background: #C3C3C3"> 
           <th align="left">Click to pick one person to Marry</th> 
           <th align="left">Girls Name/th> 
           <th align="left">Phone Number</th> 
           <th align="left">Email</th> 
         </tr> 
         @Html.EditorFor(m => m.Girls) 
        </table> 


Template 
@model MarriageDatabase.Models.Girls  
<tr> 
<td align="center" style="width:100px"> 
@Html.HiddenFor(m => m.GirlsID) 
<div class="editor-field"> 
    @Html.RadioButtonFor(m => m.GirlPicked, false) 
</div></td> 
<td style="font-weight:normal">@Html.DisplayFor(m => m.GirlsName)</td> 
<td style="font-weight:normal">@Html.DisplayFor(m => m.GirlsPhone)</td> 
<td style="font-weight:normal">@Html.DisplayFor(m => m.GirlsEmail)</td> 
</tr> 

回答

3

聽起來像你想要什麼更通常稱爲單選按鈕列表。只要所有收音機的輸入名稱相同,您應該只能選擇一個。

試試這個: How to get the selected value of the radio button list in jquery?

+0

不是列表,這會從數據庫列表。它被設置爲空,當我稍後單擊保存時,它會將結果保存到數據庫。現在我需要的是如何編輯表格中多行的單選按鈕。 – user977645

+0

你可以添加一個截圖,也許一些代碼給你的問題?這可能會使問題更清楚。 – EAnders

+0
相關問題