Click to See Complete Forum and Search --> : accessing object


ramrom
09-22-2003, 10:19 PM
Form has a radio button group. Definition begins with:

<input type="radio" value="1" name="foo" etc

JavaScript follows:
--------------------------
x = new Object()
x.a = document.formname.foo
alert(x.a[1].checked)
for (y in x){alert(y[1].checked)}
--------------------------
line 3 works fine.
line 4 fails with error " 'y.1.checked' is null or not an object"

What am I doing wrong?

Khalid Ali
09-22-2003, 10:45 PM
looks like you are rying to access an element which does not exist or its not a radio element

Charles
09-23-2003, 05:22 AM
Originally posted by Khalid Ali
looks like you are rying to access an element which does not exist or its not a radio element And I think that you will have more luck with for (y in x){alert(y.a[1].checked).