Kedar B
Kedar B

Reputation: 784

handling hidden field value in controller and model

in my view

<select id="gender" name="gender">
                              <option value="">select gender</option>
                               <option value="0">Male </option>
                               <option value="1">Female </option>


                               </select>

if gender is female then i want to show another field called "surname". following is the code

Surname 

<input type="text" name="surname" id="surname" />

And if gender is male then i want show another fields called village,district,etc. I have done hide and show code using js , so my question is how do i handle this field values in controller and model??

Upvotes: 0

Views: 44

Answers (1)

Victor York
Victor York

Reputation: 1681

Try this out:

switch($_POST['gender']){
case '0':
// do Something for 0
break;
case '1':
// do Something for 1
break;
default:
// Something went wrong or form has been tampered.
}

Upvotes: 1

Related Questions