是否有其他方法可以获取表单中所有选中复选框的值并将其显示在另一个视图中?
这是我的输入视图
<div class="col-md-6">
<input type="checkbox" name="sen_id[]" class="Form-label-radio" value="<?php echo $sen['id']; ?>" id="<?php echo $sen['id']; ?>" />
<input type="checkbox" name="sen_id[]" class="Form-label-radio" value="<?php echo $sen['id']; ?>" id="<?php echo $sen['id']; ?>" />
<input type="checkbox" name="sen_id[]" class="Form-label-radio" value="<?php echo $sen['id']; ?>" id="<?php echo $sen['id']; ?>" />
</div>
我的模特
public function view_sen($sen_id){
$sen_id[] = $this->input->post('sen_id');
foreach ($sen_id as $id) {
$this->db->select('*')->from('party_candidates')->where('id', $id);
$query[] = $this->db->get()->result_array();
}
return $query;
}
我的控制器
public function balot_form(){
$sen_id[] = $this->input->post('sen_id');
$view_sen_votes = $this->vote->view_sen($sen_id);
$data = array("view_sen_votes" => $view_sen_votes);
$this->load->view("admin_dashboard/votation_page/balot_form_page", $data);
}
显示结果视图
<div class="col-md-6">
<?php foreach($view_sen_votes as $sen => $id) { ?>
<div class="row">
<div class="form-group">
<label>Senators</label>
<input type="text" class="form-control" value="<?php echo $sen[$id]; ?>" name="sen_id" />
</div>
</div>
<?php } ?>
</div>
如何获取值并将其显示在结果视图中?谢谢,问候......
答案 0 :(得分:0)
尝试以下方法检查键值。
print_r( $view_sen_votes );