getElementById
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function btnClick() {
// alert(txtBox1.value);
var obj = document.getElementById("txtBox1");
obj.value = "button";
}
function btnClick2() {
var obj = document.getElementById("txtBox2");
obj.value = "button";
// form2.txtBox2.value = "2222";
}
</script>
</head>
<body>
<input type="text" id="txtBox1" />
<input type="button" value="点一下" onclick="btnClick()" />
<form action="Ok.aspx" id="form2">
<input type="text" id="txtBox2" />
<input type="button" value="点一下" onclick="btnClick2()" />
</form>
</body>
</html>