0

在我看来,我创建了一个动态单选按钮,其示例代码如下..

 @for (int i = 0; i < Model.ChManufacturer.Count(); i++)
  {
     if (@Model.ChManufacturer[i].Text == "Select ...")
     {
     }
     else
     {
       <td>&nbsp;&nbsp;&nbsp;<input id="manufacturer:@Model.ChManufacturer[i].Text" type="radio" name="Manu_rbgrp" value="@Model.ChManufacturer[i].Text">&nbsp;@Model.ChManufacturer[i].Text
       </td>
     }
   }

但我需要获取选定的单选按钮值。如何获取选中的单选按钮的值。例如:O abc、O bbc、O ccc。所以如果我选择第二个选项意味着它的价值是 bbc。有答案吗???我在运行时得到以下输出

<td>
<input id="manufacturer:GLI-List" type="radio" value="GLI-List" name="Manu_rbgrp">
 GLI-List
</td>
<td>
<input id="manufacturer:Latham-List" type="radio" value="Latham-List" name="Manu_rbgrp">
 Latham-List
</td>
<td>
<input id="manufacturer:Loop-Loc-List" type="radio" value="Loop-Loc-List" name="Manu_rbgrp">
 Loop-Loc-List
</td>
<td>
<input id="manufacturer:Merlin-List" type="radio" value="Merlin-List" name="Manu_rbgrp">
 Merlin-List
</td>
4

1 回答 1

1

使用onclick事件并将选定的值存储在 JS 对象或数组中。使用和获取收音机
的示例:http: //jsfiddle.net/coshmos/CBk5d/onclickid

考试代码:

<label>
<input id="SomeId" type="radio" onclick="alert(this.id);"/> Radio
</label>
于 2013-09-19T09:54:01.077 回答