jsp 中form 表单里按钮在servlet中的判断问题

来源:百度知道 编辑:UC知道 时间:2024/05/23 01:40:53
在表单中有‘修改’ 和 ‘删除’两个按钮 ,请问哪位高手知道我在servlet中怎么判断是哪个按钮被点击。而前提是我动作都在同一个servlet 中实现

给这2个button各加入一个name,通过name来判断。

给你例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>

<form id="testForm" action="" method="post">
<input type="hidden" name="op" id="op" value="" />
<input type="button" value="修改" onclick="javascript:test('update')" />
<input type="button" value="删除" onclick="javascript:test('del')" />
</form>

</body>
<script>
function test(op){
document.getElementById("op").value=op;
alert(document.getElementById("op").value);
document.getElementById("testForm").submit;
}
</script>
</html>