Forum Moderators: open
Anyway, I have what I think is a simple question. I have a page with a list of choices the user can select. Each choice has it's own radio button. Once the choice is selected, the user is then to enter more date in a text field. The code I set up looks like this:
<p><input type='radio' name='name1' value='value'>blah blah blah blah <input type='text' name='name' size='9'> blah blah blah</p>
My question is: How can I make it so that when a user clicks on the text field, it also selects the radio button? Currently the user has to click on the radio button in order to select it.
I've played around with the <LABEL> tag, when I wrap the text field in it, the radio button IS automatically selected, but the user can not gain focus on the text input field. It keeps snapping back to the radio button.
I hope I have explained well enough what I want to do. Any help would be appreciated. Thank you.
I am actually echoing the statement from a PHP script, and it seems to be getting messed up with the different quotation marks. This may be an amateur mistake, but the only way I was able to get it to work was using the concat operator in PHP to change the quotes.
The following works:
echo "<input type='text' name='name1' size='9' onclick='document.getElementById(".'"termchoice"'.").checked=true'>";
The following does NOT work:
echo "<input type='text' name='name1' size='9' onclick='document.getElementById('termchoice').checked=true'>";
Are there any more elegant ways around this, or do I have the right idea?
echo "<input type=\"text\" name=\"name1\" size=\"9\"
onclick=\"document.getElementById('termchoice').checked=true\">";
echo '<input type="text" name="name1" size="9"
onclick="document.getElementById(\'termchoic\').checked=true">';
if you don't need variable expansion
[php.net...]