[英]How to update page asynchronously
这是我的代码:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form>
<table>
<tr>
<td>
<input type="text" name="input" size="20" class="FormText" readonly />
<td />
<tr />
<tr>
<td>
<input type="button" name="one" value="1">
<td />
<tr />
</table>
</form>
</body>
</html>
我想要当按钮1被按下以在同一页面的输入字段中显示1时。 我知道这是通过Ajax实现的,但我做不到。 我读了很多文章,但无济于事。
您可以使用javascript
来做到这一点。 看一下如下:
function addValue(value) {
document.form.input.value=value;
}
您必须在javascript
部分中设置此javascript
源代码(通常将其放置在头代码中)。
为了调用该代码,您应该告诉'button'函数的定义位置:
<input type="button" name="one" value="1" onClick='addValue(1)'>
就这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.