View Full Version : How to change the checked item on a radio type with javascript

10-13-2005, 04:41 PM
I am trying to update the checked radio item with javascript. I need to do this after the HTML page has been written and therefore am using javascript.

Basically I have a javascript function like this:

Function updatewin(){

Var index;

Index = document.main.index.value = 1;

Mywin.document.form.radio[index].checked = true;


When I run this in IE I get an error index is null or not an object.

If I try hardcoding 1 in the square brackets it works fine and selects the correct radio button.

Any ideas?

10-13-2005, 11:38 PM
JS does not support values on both the left and right hand side of an equals sign. It IS case-sensitive. Index != index.

var index = 1;
Mywin.document.form.radio[index].checked = true;