I am trying to pass the selected value into a hidden field but I always get the last value of option.
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo get_phrase('section');?></label>
<div class="col-sm-5">
<select name="section_id" class="form-control selectboxit" style="width:100%;">
<?php
foreach($sections as $row):
?>
<option value="<?php echo $row['section_id'];?>"><?php echo $row['name'];?></option>
<?php endforeach;?>
</select>
</div>
</div>
<input type="text" name="section_id" value="<?php echo $row['section_id']?>">
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo get_phrase('subject');?></label>
<div class="col-sm-5">
<select name="subject_id" class="form-control selectboxit" style="width:100%;">
<?php
$subjects = $this->db->get_where('enroll' , array('section_id' => $section_id))->result_array();
foreach($subjects as $row):
?>
<option value="<?php echo $row['student_id'];?>"><?php echo $row['name'];?></option>
<?php endforeach;?>
</select>
</div>
</div>
i want to pass the hidden field value to query inside the second dropdown how to do this