function setdata(){
document.getElementById("userName").value="hello_world"
}
</script>
<form>
<input id="userName" type="text" />
</form>
<div onclick="setdata()">set data</div>
不知道你所要的确切效果,但是改一下该没问题
<html><head>
<script type="text/javascript">
function doSubmit(){
var userName=document.getElementById("userName").value
var userPass=document.getElementById("userPass").value
document.getElementById("user").innerHTML=":"+userName
document.getElementById("psd").innerHTML=":"+userPass
return false
}
</script>
</head>
<body>
<table border="1" width="500" align="center">
<thead >
<tr>
<td>账号<span id='user'></span></td><td>密码<span id='psd'></span></td><td>地址</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<hr color="red">
<form onsubmit="return doSubmit()">
userName:<input type="text" id="userName">
<br />
userPass:<input type="password" id="userPass">
<br />
<input type="submit" value="提交">
</form>
</body>
</html>