Claudius Massery
Claudius Massery

Reputation: 95

how to display different input box depend value option select

in need your help. i have option select:

Relationship:

<?php
$relationship=array(
''=>'Choose relationship',
'child'=>'child',
'guardian'=>'guardian',
'parent'=>'parent',
'wife'=>'wife',
'husband'=>'husband',
'mother in law'=>'mother in law',
'futher in law'=>'futher in law'
);

echo form_error('relationship');<br />
echo form_dropdown('relationship', $relationship, set_value('relationship'), array('id'=>'relationship'));
?>

how can i make input box to appear if selection is made? example if i choose mother i want input box for address to appear, if i choose child i want input box for birth date to appear...

Upvotes: 0

Views: 281

Answers (1)

AnatPort
AnatPort

Reputation: 748

trigger an event when an option is selected, then check which option was selected and display the input box accordingly. for example:

    $('selectbox').on('change', function (e) {
    if( this.value == 'mother')
      {
        $('addressinput').show();
      }
    });

Upvotes: 2

Related Questions