[eluser]shankar ganesh[/eluser]
The below code for controller
Code:
<?php
class All_controls extends Controller
{
function All_controls()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
$this->load->library("validation");
}
function index()
{
$data['location'] = array(""=>"Select","1"=>"Coimbatore","2"=>"Chennai","3"=>"Madurai");
$data['loc_select'] = array("1");
$data['parttime'] = array('name'=>'parttime','id' =>'parttime','value'=> 'part','checked'=> TRUE);
$data['fulltime'] = array('name'=>'fulltime','id' =>'fulltime','value'=> 'full','checked'=>FALSE);
$data['male_gender'] = array('name'=>'gender','id' =>'gender_male','value'=> 'Male','checked'=> TRUE);
$data['female_gender'] = array('name'=>'gender','id' =>'gender_female','value'=> 'Female','checked'=>FALSE);
$data['department'] = array(""=>"Select","1"=>"EIT","2"=>"Offshore","3"=>"Testing","4"=>"Marketing");
$data['dept_select'] = array("1","2");
$this->load->view("controls",$data);
}
function validate()
{
echo '<pre>';
print_r($_POST);
echo "<br/>";
$this->input->post('department');
echo "Validated";
}
}
?>
The below code for view
Code:
<html>
<body>
<?php echo form_open('all_controls/validate');?>
<table border="0">
<tr>
<td>Name</td>
<td><input type="text" value="" name="name" id="name"></td>
</tr>
<tr>
<td>Gender</td>
<td><?php echo form_radio($male_gender);?>Male <?php echo form_radio($female_gender);?>Female</td>
</tr>
<tr>
<td>Job type</td>
<td><?php echo form_checkbox($parttime);?>Part Time <?php echo form_checkbox($fulltime);?>Full Time</td>
</tr>
<tr>
<td>Location</td>
<td><?php echo form_dropdown('loaction', $location, $loc_select,'id=location');?></td>
</tr>
<tr>
<td>Department</td>
<td><?php echo form_dropdown('department', $department, $dept_select,'id=department');?></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit" name="sub" id="sub"></td>
</tr>
</table>
</body>
</html>