猿问

PHP复选框值发布以使用Codeigniter框架进行查看

从php表单中发布选定复选框的值以在codeigniter框架中查看


PHP形式


<input type='checkbox' value="<?php echo $row_id ?>">

<input type='hidden' name='asap[]' value="1 " >

<input type='hidden' name='asap[]' value="2 " >

<input type='hidden' name='asap[]' value="3 " >

控制器


$asap=> $this->input->post('asap')

看法


echo $asap;

复选框的值不显示在视图中


蝴蝶刀刀
浏览 109回答 2
2回答

慕勒3428872

看法:<input type='checkbox' name='cname' value="<?php echo 'cvalue'; ?>">//changes<input type='hidden' name='asap[]' value="1" ><!--removed right space from value--><input type='hidden' name='asap[]' value="2" ><!--removed right space from value--><input type='hidden' name='asap[]' value="3" ><!--removed right space from value-->控制器://here you have syntax error use `=` instead `=>`$postData = $this->input->post();//you get all your post data, if you added `name` attribute onlyprint_r($postData);//it will return you first hidden valueprint_r($postData['asap'][0]);echo '------------';echo 'loop values';$asap = $this->input->post('asap');foreach($asap as $row){&nbsp; &nbsp; &nbsp; &nbsp;echo $row.'<pre>';}输出:Array(&nbsp; &nbsp; [cname] => cvalue&nbsp; &nbsp; [asap] => Array&nbsp; &nbsp; &nbsp; &nbsp; (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [0] => 1&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [1] => 2&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [2] => 3&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ))1----------loop values123
随时随地看视频慕课网APP
我要回答