duanbi1888 2014-05-24 13:57
浏览 42
已采纳

表单codeigniter上的两个不同的提交按钮表现得很奇怪

I have two buttons on one submit form but when I post the submit button it returns nothing;"ABOUT THE BUTTON"; the other data is retrieved WELL.

I have been using different names for the submit button but nothing works.. Could someone help me? thank you. The FORM data is retrieved well but not the submit button value? i need the value to differ the condition

controller: admin.php

        function submit_unitgroupwd(){
        $this->access_chk(); //CHECK USER ACCESS

    $sbm=$this->input->post('sbm'); // returns NOTHING
   echo $_POST["sbm"]; // returns undefined index sbm
   echo $_POST['sbm']; // returns undefined index sbm
var_dump($_POST); // returns all the post data bt the submit button

 //echo var_dump($this->input->post("sbm"));
exit();

if($this->input->post('sbm') == "Update") { 
// do update
} else {
// do delete
}

}

view:

 echo "<form action=".site_url("admin/submit_unitgroupwd")." method=post id=form>"; 
echo "<div style='float:left;color:red;' id='res'></div>";
?><?php 
foreach($q1->result_array() as $r1){
$bankname= substr($r1["bank"],0,3);
//echo $bankname;


echo "<input type=hidden name=dgroup value='".$dgroup."'>";
echo "<tr>";
echo "<td width=20% colspan=3 style='font-size: 16px;'>".strtoupper($r1["bank"])."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=100>".$group_[0]."</td>";
echo "<td><input type=text name='$bankname-utama' value='".str_replace(" ","",$r1["utama"])."' style='width: 100%;'></td>";

if ($r1["bank"] == 'ALL'){
    echo "<td rowspan='1'><br><input type='checkbox' name='cek[]' id='cek[]' value='$bankname' ></td>";

    echo "<input type=hidden name=_code$bankname value='".$r1["bank"]."'>";
    echo "</tr>";
    echo "</tr>";
    continue;
}

echo "<td rowspan=".($dgroup + 1)."><br><input type='checkbox' name='cek[]' id='cek[]' value='$bankname' ><br><br><br><br><br><br><br>";
echo "<input type=hidden name=_code$bankname value='".$r1["bank"]."'>";

echo "</tr>";

$_alp = "a";
for ($_g=0; $_g<$dgroup; $_g++){
    echo "<tr>";
    echo "<td width=100>".$group_[($_g + 1)]."</td>";
    echo "<td width=80%><input type=text name='$bankname-wd$_alp' value='".str_replace(" ","",$r1["wd$_alp"])."' style='width: 100%;'></td>";
    echo "</tr>";
    $_alp++;
echo "</tr>";

}
}
?>
>
<input type="submit" class="button" value='Update' name="sbm"/>
<input type="submit" class="button" value='Delete' name="sbm"/>
  • 写回答

2条回答 默认 最新

  • duanaozhong0696 2014-05-24 15:10
    关注

    You could simply use only the

     <input type="submit" class="button" value='Update' name="sbm"/> 
    

    and use an anchor for the delete action,

    echo "<a href ='controller_delete/$item_id' class='button'>Delete</a>
    

    since you normally wont need other inputs on the delete action if you get my point.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP