日期:2014-05-16  浏览次数:20685 次

form 表单提交 疑问


<form onsubmit="return delInfo()" action="" method="post" >

<table>

<tr><td>aa</td></tr>
</table>

<input type="submit" value="全部删除" >&nbsp;&nbsp;
<input type="submit" value="发送信息" >
</form>

--------------------------
怎么在一个form 里面可以点击不同的按钮 连接不用action 方法地址

------解决方案--------------------
<script type="text/javascript">
function del(){
document.form[0].action = "你想执行的方法";
document.form[0].submit();
}
function send(){
document.form[0].action = "你想执行的方法";
document.form[0].submit();
}
</script>
<form method="post" >

<table>

<tr><td>aa</td></tr>
</table>

<input type="button" value="全部删除" onclick=“del()”>&nbsp;&nbsp;
<input type="button" value="发送信息" onclick=“send()”>
</form>

------解决方案--------------------
<script type="text/javascript">
function deleteAll(){
document.URL = "XXXX.action";
document.getElementById("bt_del").submit();
}
function sendMessage(){
document.URL = "XXXX.action";
document.getElementById("bt_send").submit();
}
</script>

<form onsubmit="return false" method="post" >

<table>

<tr><td>aa</td></tr>
</table>

<input id="bt_del" type="button" onClick="deleteAll();" value="全部删除" >&nbsp;&nbsp;
<input id="bt_send" type="button" onClick="sendMessage();" value="发送信息" >
</form>