Gerard van Wilgen wrote:
I noticed that the following line of code works in IE 6 but not in Netscape
7.1:
<INPUT TYPE="radio" NAME="selComb" VALUE="0"
ONCLICK="alert( selComb[0].value)">
Nothing happens when I click on the radio button. There is not even an error
message.
This is a simplified version of the actual code, which is used to pass among
other things the value of a selected radio button to a JavaScript-function.
Does anybody know how this code can be made to work in Netscape?
Gerard van Wilgen
If you want to pass the radio button value to a function, how about
onlick="alert(t his.value);"
If you want to access the values of radio buttons in a form, you can do
it using the forms collection and form elements collection. You can
access the form by it's number or by it's name:
document.forms['formname']
document.forms[formumber]
To access a radio button, you can use its element number in the form, or
it's name and index number, which might be more convenient if you have
several mixed types of form elements:
Selcomb 0 <input type="radio" name="selComb" value="0"
onclick="alert( document.forms['frmData'].elements[0].checked)">
Selcomb 1 <input type="radio" name="selComb" value="1"
onclick="alert( document.forms[0].elements[0].checked)">
Selcomb 2 <input type="radio" name="selComb" value="2"
onclick="alert( document.forms['frmData'].selComb[0].checked)">
Selcomb 3 <input type="radio" name="selComb" value="3"
onclick="alert( document.forms[0].elements[selComb,[0]].checked)">
Mike