Welcome Guest, Not a member yet? Register   Sign In
How to use form_radio for a multiple choice type of question
#1

[eluser]AlanW[/eluser]
I'm not clear on how to use the form_radio function to create a form that has 4 options, only one of which is right.

I envision have 4 radio buttons with the options, so that if one option is chosen, the others are automatically deselected.

Once the form is submitted, only the selected option gets passed….

Is that how the form_radio could work?

Thanks in advance!
#2

[eluser]web_developer[/eluser]
Code:
form_radio(array("name"=>"newuser","id"=>"newuser_1","value"=>"1", 'checked'=>set_radio('newuser', '1', TRUE)));  
form_radio(array("name"=>"newuser","id"=>"newuser_2","value"=>"2", 'checked'=>set_radio('newuser', '2', TRUE)));  
form_radio(array("name"=>"newuser","id"=>"newuser_3","value"=>"3", 'checked'=>set_radio('newuser', '3', TRUE)));  
form_radio(array("name"=>"newuser","id"=>"newuser_4","value"=>"4", 'checked'=>set_radio('newuser', '4', TRUE)));
#3

[eluser]PhilTem[/eluser]
A form radio works just like a select (also called dropdown) with only a different styling (and actually a different markup, but we don't want to focus on that).

Having a dropdown only submits one value at time of submit. The same goes for radio buttons, they only submit one value on form submit.




Theme © iAndrew 2016 - Forum software by © MyBB