I have a multiple select box:
<select name="tar[]" multiple="multiple" style="height:100px;" id="select1">
<?php foreach($lists as $list){ ?>
<option value="<?php echo $list['des_id']; ?>"><?php echo $list['designation']; ?></option>
<?php } ?>
</select>
At controller i am trying to get the values of selected fields,but failed to get that and i am getting values like 2 or 3.
$target = $this->input->post('tar');
print_r($target);die;
Am i doing right??please guide me.Thanks.
I am not sure but try this to get all tars
foreach($this->input->post("tar") as $tar){
echo $tar;
}
okay i got the answer...
here is i am wrong,just i have to define the array in controller:
$target['tar'] = $this->input->post('tar');
print_r($target);die;
You can also use Core PHP style,because Core PHP is the top of all framework:
if(isset($_POST['tar'])){
foreach ($_POST['tar'] as $tar_value){
print "You are selected $tar_value<br/>";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.