This topic is locked
[SOLVED]

 Check/uncheck Radio Buttons

11/16/2010 10:55:25 AM
ASPRunnerPro General questions
J
Jay123 author

Hi!
I am using ASP Runner 6.1.
I would like to ask what is the correct javascript syntax to manipulate the state of different radio buttons. I have 2 radio buttons (different fields). I would like radio button 1 to be unchecked if radio button 2 is checked and vice versa.
Thanks,

Jay

Sergey Kornilov admin 11/16/2010

Don't have a complete example for this though here is the article that can help:

http://www.java2s.com/Code/JavaScript/Form-Control/CheckaRadioButton.htm

J
Jay123 author 11/17/2010

Hi Sergey,
The link cannot display the page.
Do you have any clue on what's wrong with this code? It doesn't return any error but it doesn't do anything either.
<script>

document.forms.editform.value_field1.onClick = function()

{

if(document.forms.value_field1.checked==true)

{

document.forms.value_field2.checked=false;

}

}

</SCRIPT>
Thanks,

Jay

Sergey Kornilov admin 11/17/2010

Here is the correct link:

http://www.java2s.com/Code/JavaScript/Form-Control/CheckaRadioButton.htm
Unfortunately it's not possible to tell if your code right or wrong simply looking at it. You need to troubleshoot it.

I recommend to check 'How to to troubleshoot Javascript errors using Firebug' video at http://xlinesoft.com/asprunnerpro/tutorial.htm
This way you can see if there are any errors, if your code runs at all etc.

J
Jay123 author 11/25/2010

Thanks, Sergey.
I found a work around by using a checkbox that behaves like a radio button.

<script>

document.forms.editform.value_field1.onclick = function()

{

if(document.forms.editform.value_field1.checked == true)

{

document.forms.editform.value_field2.checked = false;

}

}

document.forms.editform.value_field2.onclick = function()

{

if(document.forms.editform.value_field2.checked == true)

{

document.forms.editform.value_field1.checked = false;

}

}

</SCRIPT>