【发布时间】:2016-08-01 13:12:07
【问题描述】:
嗨,我想在代码点火器中以一种形式有两个提交按钮。可能吗?我想做两个按钮,它们会做同样的事情,将数据添加到数据库中,按钮的唯一区别是它们将重定向到哪个页面。
这是我的代码,
<?php
echo form_open('EmpFamilyInfo/add_childinfo/'.$this->uri->segment(3));
?>
// some textboxex,
<div class="box-body">
<div class = 'col-md-6 col-sm-offset-6'>
<button class="btn btn-info fa fa-save" type="submit">  Save</button>
<a href = '<?php echo base_url().'EmpFamilyInfo/other_childinfo/'.$this->uri->segment(3); ?>' class = 'btn btn-primary fa fa-save' >  Add Another</a>
<a href = '<?php echo base_url().'EmpFamilyInfo/parentsinfo_father/'.$this->uri->segment(3); ?>' class = 'btn btn-danger fa fa-arrow-circle-right'>  Skip</a>
<?php
echo form_close();
?>
</div>
</div>
我已经制作了这个代码,第一个链接echo form_open('EmpFamilyInfo/add_childinfo/'.$this->uri->segment(3));我想要这样做是
public function other_childinfo(){
$this->form_validation->set_rules('NAME', 'Name of Child' ,'trim|required|max_length[100]');
if($this->form_validation->run($this) == FALSE){
$this->child_info();
}else{
if($query = $this->EmpFamilyInfo_Model->insert_childinfo()){
redirect('EmpFamilyInfo/child_info/'.$this->uri->segment(3));
}else{
$this->child_info();
}
}
}
但错误是,它没有发布数据。我怎样才能让这个链接成为提交按钮,但它会转到不同的功能,或者我怎样才能让它拥有发布数据?
【问题讨论】:
-
你的代码有
two anchor tag而不是两个提交按钮!! -
是的。我知道。我希望其中一个用作提交按钮。
-
imo - 为提交按钮指定不同的名称,然后检查控制器中实际使用的名称并根据需要重定向?无需 javascript。
标签: php forms codeigniter