user519846
user519846

Reputation: 1009

How should we use radio group in codeigniter

I am using codeigniter framework for one of my PHP project.

In form I want to use radio button for gender.

Gender * Male * Female

With the value 1 or for male and 2 for female.

after selection radio button value should be assign to gender.

Can any tell me how to acheive this in codigniter.

Thanks in advance.

Upvotes: 0

Views: 12563

Answers (3)

Janisha Narola
Janisha Narola

Reputation: 1

in view file :

<input type="radio" name="gender" value=1 />Male
<input type="radio" name="gender" value=2 />Female

and in controller its looks like i show you below

$user_type=$this->input->post('radio');

Upvotes: -1

Pramod Kumar Sharma
Pramod Kumar Sharma

Reputation: 8012

Try Something like this

<tr><td><?php echo form_radio('gender', '1', TRUE); ?></td><td><?php echo form_label('Male', 'gender');?></td></tr>
<tr><td><?php echo form_radio('gender', '2', FALSE); ?></td><td><?php echo form_label('Female', 'gender');?></td></tr>

Upvotes: 3

Miqdad Ali
Miqdad Ali

Reputation: 6147

You can use the html tag for creating any input in codeigniter

 <input type="radio" name="gender" value=1 />Male
 <input type="radio" name="gender" value=2 />Female

Upvotes: 0

Related Questions