日期:2014-05-17  浏览次数:20899 次

初级问题,送分!
用vbscript脚本。按钮事件,对一个文本框赋值
如:
<SCRIPT   LANGUAGE= "VBScript "   Runat= "Server ">  
Sub   cmdChangeIt_onClick
Dim   TheForm
Set   TheForm   =   Document.MyForm     '错误提示:缺少对象:  
MyForm.txt.value= "good "

End   Sub

If   Request.ServerVariables( "REQUEST_METHOD ")   =   "POST "   Then
        If   Request.Form( "cmdChangeIt ")   =   "ent "   Then
              Call   cmdChangeIt_onClick
             
               
        End   If
End   If

</SCRIPT>  
<HTML>
<HEAD> <TITLE> </TITLE>
</HEAD>
<BODY>
<HR>
<FORM     id= "MyForm "   name= "MyForm "   method= "post "   action= "test.asp ">
<INPUT   TYPE= "submit "   NAME= "cmdChangeIt "   VALUE= "ent "   />
<input   name= "txt "   type= "text "   id= "txt "     />


</FORM>
</BODY>
</HTML>


我想按钮后对文本框赋值,怎么做?   另,问 <!--     //-->   在vbscript里表示什么意思?谢谢


------解决方案--------------------
<INPUT TYPE= "submit " NAME= "cmdChangeIt " VALUE= "ent " onclick= "txt.value= 'x ' " />
------解决方案--------------------
<!-- //--> ,都是些文档说明性东西,可以保证符合某某某标准。(W3C)
------解决方案--------------------
<SCRIPT LANGUAGE= "VBScript " Runat= "Server ">

你这是服务端脚本 而非客户端

用JS可以这样获取

document.all[ "txt "].value
------解决方案--------------------
<script type= "text/javascript ">
document.getElementById( "txt ").value = "good ";
</script>
------解决方案--------------------
去掉Runat= "Server "试试
------解决方案--------------------
document.all[ "名称 "].value
or
document.getElementById( "ID值 ").value