关于jsp提交到本页面,并显示表单传值

来源:百度知道 编辑:UC知道 时间:2024/05/29 15:48:28
<html>
<head>
<title>hello!</title>
<script language="javascript">
function bn_click(){
frm.action="result.jsp"
frm.submit();
}
</script>
<form name="frm" method=post >
<input type="text" value="" name="txt1">+<input type="text" value="" name="txt2">
<input type="submit" name="submit1" value=" = " onclick="bn_click()">
</form>
<body>
值:<br>
<%@ page contentType="text/html;charset=gb2312"%>
<H2>result.jsp:</H2>
<% String text1 = "";
String text2 = "";
String text3 = "+";
String text4 = "=";
text1=request.getParameter("txt1");
text2=request.getPara

其实想这种的问题,可以在页面直接用JavaScript处理
<html>
<head>
<title>hello!</title>
<script language="javascript">
function bn_click(){
var txt1 = parseInt(frm.txt1.value);
var txt2 = parseInt(frm.txt2.value);
var sum = txt1 + txt2;
frm.sum.value = sum;
}
</script>
<body>
<form name="frm" method=post >
<input type="text" value="" name="txt1" size=5>+
<input type="text" value="" name="txt2" size=5>=
<input type="text" value="" name="sum" size=6>
<input type="button" value="计算" onclick="bn_click()">
</form>
</body>
</head>
</html>

你的代码问题应该在这个按钮上
<input type="submit" name="submit1" value=" = " onclick="