怎么确定form表单里点击了的是哪个submit按钮

来源:百度知道 编辑:UC知道 时间:2024/06/14 00:43:14
我有个表单里面有两个按钮,分别是“同意”和“拒绝”
我想根据不同的点击按钮的操作执行不同的操作(写数据库)
请问这要怎么写?

<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript">
function agree(){
document.testForm.answer.value = "你点了同意";
//document.testForm.submit();
}
function Unagree(){
document.testForm.answer.value = "你点了拒绝";
//document.testForm.submit();
}
</script>
</head>
<body>
<form action="noPage" name=testForm>
信息:<input type="text" name="answer" />
<input type="button" onclick="agree()" value = "同意" />
<input type="button" onclick="Unagree()" value = "拒绝" />
</form>
</body>
</html>

用javascript不就行了。

<input type="button" value="同意" onclick="fun1()">
<input type="button"