Welcome Guest, Not a member yet? Register   Sign In
form_radio() and form_dropdown() .. array data . how to ?
#1

[eluser]Nano HE[/eluser]
Hi,
Good day.

I am newbie. i got two quesions about form_radio() and form_dropdown()
Q1, How to rewrite the following snatch code with form_radio.



Code:
echo "<p><label for='gender'>Gender</label><br/>";
$options = array('male' => 'male', 'female' => 'female');
echo form_dropdown('gender',$options) ."</p>";

Q2, How to get 2nd form_dropdown $options categoried based on the 1st form_radio selected.

that means.
1st. if i selected (form_radio) item "Male"
2nd. i could select the (form_dropdown) list items which only related with Male. (Male 20-29, Male30-39, etc.)
3rd. and the other Female related items will hide, not show on the dropdown list.
4th. conversely when i selected (form_radio) item "Female". Only show (Female20-29, etc.)

=====================================

Comment: Q1 soluted. thanks
#2

[eluser]Nano HE[/eluser]
Revised.

My CI race registration form.
http://www.ironmanchina.net/active/index.php/form/

When user selected the gender, such as "Male".
How to only show the Male related the race groups at the below "Race Category Select" form_dropdown() list.

Anybody could give me a hand?
Any help will be appreciated.

:-)
#3

[eluser]rogierb[/eluser]
jquery:-)
<code>
$("input[name=gender]").change(function(){

$("select[name=category] option[gender!="+$(this).val+"]").hide();
$("select[name=category] option[gender="+$(this).val+"]").show();
})
</code>
1: Add a gender attribute to the select options
2: Just hide the options (wrong gender) on change of gender and show the ones with the right gender
3: IE can be a bit buggy when referencing to the options in a select




Theme © iAndrew 2016 - Forum software by © MyBB