<html>
<body>
<form action="first.jsp" method ="get">
first number<input type="text" name="n1"><br>
Second number<input type="text" name="n2"><br>
<input type="submit" name="s1">
</form>
<%
String n1 = request.getParameter("n1");
String n2 = request.getParameter("n2");
int i1 = Integer.parseInt(n1);
int i2 = Integer.parseInt(n2);
int i3 = i1+i2;
%>
Result<input type="text" name="n3" value =<%=i3 %>>
</body>
</html>
我应该创建单独的jsp和html页面 如果是,那么我该如何在n3中打印该值 如何在n3
中打印添加值答案 0 :(得分:1)
<html>
<head>
<script>
function addition()
{
var a = parseInt(form.input1.value);
var b = parseInt(form.input2.value);
var c = a+b;
document.getElementById("aa").value = c;
}
</script>
</head>
<body>
<form name="form" method="GET">
First Number
<input type="text" name="input1" value=20><br>
Second Number
<input type="text" name="input2" value=10><br>
<input type="button" value="Add" onclick="addition()">
Result
<input type="text" id="aa" name="input3" ><br>
</form>
</body
</html>