【求代码】点击按钮后,将文本自动输入到文本框

求各位指导下,帮我写一段代码我需要的效果是:点击按钮后,将本页获取的两个参数自动输入到当页的文本框中具体如图

第1个回答  2013-06-13
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<script>
function test(){
document.getElementById("p1").value= document.getElementById("s1").innerHTML;
document.getElementById("p2").value= document.getElementById("s2").innerHTML;
}
</script>
<body>
<div>名称:<span id="s1">rs("username")</span></div>
<div>等级:<span id="s2">rs("dengji")</span></div>
<div><input type="button" onclick="test();" value="填入文本框>>"></div>
<div><input type="text" id="p1"/></div>
<div><input type="text" id="p2"/></div>
</body>
</html>
相似回答