I am creating an HTML form with some radio button options. I’d like to have one option as ‘Other – please specify’ and allow the user to type something in.
Two questions:
1) How can I make a ‘hybrid’ input type of radio/text?
2) On the PHP back end, if the input has the same name attribute as the radio inputs, will the user’s input be part of the same array?
#1: To the ‘other:’ radio field, add a
<input type='text' ...>with style display:none and only display it when user selects the ‘other:’ radio field.However, I’m not entirely sure if #2 would work. You’d get
rboption=otherfrom the radio button ANDrboption=some%20textfrom the text field. One will usually overwrite the other, but it’s not sure which (read: depends on position in page, browser and phase of the moon).To be sure, make the textfield name different and only process it when
rboption == 'other'(like Salty said)