« javascript radio button tree | Main | javascript command interpreter »

javascript change radio button properties

By admin | January 3, 2008

How do you change a radio control in a form using javascript?

Read this article to find out

Lets assume we have a simple Form with a 2 state radio button

<form name="example">
One:
<input name="test" type="radio" />
Two:
<input name="test" type="radio" />
</form>

We can set the first to be checked like this…

<script type="text/javascript">
<!--
document.example.test[0].checked = true;
//-->
</script>

and the second to be checked like this…

<script type="text/javascript">
<!--
document.example.test[1].checked = true;
//-->
</script>

Some other sites that might help you :

http://www.webmasterworld.com/forum91/889.htm
http://www.javascriptkit.com/javatutors/radiocheck.shtml

Topics: all, javascript |

Comments