Is it possible to use an input within a <label> field?

Posted by javanix on Stack Overflow See other posts from Stack Overflow or by javanix
Published on 2010-04-28T17:57:31Z Indexed on 2010/04/28 18:17 UTC
Read the original article Hit count: 268

Filed under:
|
|
|

I have a bunch of optional "write-in" values for a survey I'm working on.

These are basically a radio button with a textbox within the answer field - the idea being that you would toggle the button and write something into the box.

What I'd like to do is have the radio button toggled whenever a user clicks in the text field - this seems like a use-case that makes a lot of sense.

Doing this:

<input type="radio" id="radiobutton"><label for="radiobutton">Other: <input type="text" id="radiobutton_other"></label>

works fine in Chrome (and I am guessing, other WebKit browsers as well), but there are weird selection issues in Firefox, so I'm assuming its a non-standard practice that I should stay away from.

Is there a way to replicate this functionality without using JavaScript? I have an onclick function that will work, but we're trying to make our site usable for people who might have NoScript-type stuff running.

© Stack Overflow or respective owner

Related posts about html

Related posts about input