0

In my view i create a dynamic radio button the sample code of this is as follows..

 @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>
     }
   }

but i am in need of get the selected radiobutton value. How to get the values of a checked radiobutton.. For Ex: O abc , O bbc, O ccc. So if i select the 2nd option means ithe value is bbc. Any answer??? i got the following output at the runtime

<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>
tereško
  • 58,060
  • 25
  • 98
  • 150
Jasper Manickaraj
  • 797
  • 3
  • 12
  • 35
  • I think this is what you mean.. hope this will help: http://stackoverflow.com/questions/3869535/how-to-get-the-selected-radio-button-value-using-js or here http://stackoverflow.com/questions/15839169/how-to-get-value-of-selected-radio-button – propaganja Sep 19 '13 at 09:39

1 Answers1

1

Use the onclick event and store selected values in a JS object or array.
Example using of the onclick and getting the id of a radio: http://jsfiddle.net/coshmos/CBk5d/

Code of the examle:

<label>
<input id="SomeId" type="radio" onclick="alert(this.id);"/> Radio
</label>
Mark Twain
  • 826
  • 14
  • 26