N
namanhvu
Hi everyone,
I'm trying to create a form where the radio button is automatically
selected when the input text field beside it is clicked. I know I need
to use "onClick" somewhere but I don't know how.
With links I found it it would work like this:
<SCRIPT LANGUAGE="JavaScript">
function click(which) {
document.theForm.theRadio[which].checked = true;
}
</SCRIPT>
<FORM NAME="theForm">
<INPUT TYPE="RADIO" NAME="theRadio" CHECKED> <A
HREF="javascript:click(0)">Click this</A>
<BR>
<INPUT TYPE="RADIO" NAME="theRadio"> <A
HREF="javascript:click(1)">Click this</A>
</FORM>
However, with input fields, it didn't work when I tried this:
<FORM NAME="theForm">
<INPUT TYPE="RADIO" NAME="theRadio" > Button A <input type="text"
name="blah2" onClick="javascript:click(0)">
<BR>
<INPUT TYPE="RADIO" NAME="theRadio"> Button B <input type="text"
name="blah2" onClick="javascript:click(1)">
</FORM>
Can anyone help me please?
TIA.
I'm trying to create a form where the radio button is automatically
selected when the input text field beside it is clicked. I know I need
to use "onClick" somewhere but I don't know how.
With links I found it it would work like this:
<SCRIPT LANGUAGE="JavaScript">
function click(which) {
document.theForm.theRadio[which].checked = true;
}
</SCRIPT>
<FORM NAME="theForm">
<INPUT TYPE="RADIO" NAME="theRadio" CHECKED> <A
HREF="javascript:click(0)">Click this</A>
<BR>
<INPUT TYPE="RADIO" NAME="theRadio"> <A
HREF="javascript:click(1)">Click this</A>
</FORM>
However, with input fields, it didn't work when I tried this:
<FORM NAME="theForm">
<INPUT TYPE="RADIO" NAME="theRadio" > Button A <input type="text"
name="blah2" onClick="javascript:click(0)">
<BR>
<INPUT TYPE="RADIO" NAME="theRadio"> Button B <input type="text"
name="blah2" onClick="javascript:click(1)">
</FORM>
Can anyone help me please?
TIA.