我有html表单如何知道点击了哪个按钮?
我使用,而不是<a href="#" onclick="document.aa.submit()">
提交按钮
我的代码会解释我的问题越好..
<html>
<form name="aa" action="aa.php" method="post">
<input type="checkbox" name="posts[]" value="1">
<input type="checkbox" name="posts[]" value="2">
<a href="#" onclick="document.aa.submit()">Delete</a>
<a href="#" onclick="document.aa.submit()">Move</a>
</form>
</html>
aa.php
<?php
print_r($_POST);
?>
结果
Array ([posts] => Array ([0] => 1 [1] => 2))
现在的问题是:
如何知道用户点击删除或移动?
注:
我知道如果我用<input submit>
将修复该问题
,但我不能使用某种原因
注2
的问题是如何提交按钮通过php来检测它。
?例如:
Array ([posts] => Array ([0] => 1 [1] => 2 ['submit'=>'delete']))
if('delete'){
mysql_query("delete from...")
}
else{
mysql_query("update/move ....");
}
在a元素上使用ID标签?发布id并用php表单检索它。 – Brendan
使用ID标签来区分元素! – alibenmessaoud
可能重复[多个提交按钮在窗体中](http://stackoverflow.com/questions/3540585/multiple-submit-button-in-a-form) – miku