-1

I have some straight HTML code

<input type="radio" name="GRSReboot" value="1" checked >On</input>
<input type="radio" name="GRSReboot" value="2" >Off</input>

I need to set the checked value of the field using jquery.

I do not want to use the runat=server options, so i need to know, how do i tell JQuery to set the value of the radio button group?

thank you

Edit - The controls are a radio button group, and i need to set one of the controls as checked based on a value returned from the server. thank you

pithhelmet
  • 2,222
  • 6
  • 35
  • 60

2 Answers2

2

Check demo here

It's a bit unclear for me if you want to check/uncheck or give it a value.

If you want to give it or change it's value, you can use this:

$("input[name=GRSReboot]").prop('value','200');

If you want to change the value of the checked one you can use:

$("input[name=GRSReboot]:checked").prop('value','200');
Sergio
  • 28,539
  • 11
  • 85
  • 132
1

Try this:

$("input[type=radio]").attr('checked', 'checked');
Jonny Sooter
  • 2,417
  • 1
  • 24
  • 40