举个栗子:
<html><HEAD></HEAD><BODY> <form id="form1" method="post" > <TABLE border="1" style="width:560"> <script type="text/javascript" language="Javascript1.1"> var text="aaa"; </script> <TR><TD nowrap class="tdLeft">信息来源</TD> <TD> <input type="text" size="30" value=""> </TD></TR> </TABLE></form></BODY></html>
怎么将变量text的值赋给文本域<input type="text" size="30" value="">
解决方案:
<html><HEAD></HEAD><BODY> <form id="form1" method="post" > <TABLE border="1" style="width:560"> <TR><TD nowrap class="tdLeft">信息来源</TD> <TD> <input type="text" size="30" value="" id="text1"> </TD></TR> </TABLE></form></BODY> <script type="text/javascript"> var text="aaa"; document.getElementById("text1").value = text; </script> </html>
时间: 2024-10-12 11:33:43