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

急!!!asp代码如何获取inputbox的返回值?
我用VBScript编写了一个函数chk(),是让用户在点击按钮的时候弹出提示 "输入开工日期的对话框 ",然后将文本框的值赋给form1的kaig_time隐藏值.代码如下:

<script   language= "VBScript ">
Function   chk()
chk   =   inputbox( "请输入开工日期(如:207-1-23) ", "请输入开工日期 ",date())
document.form1.kaig_time   =   CDate(chk)
document.form1.submit()
End   Function
</SCRIPT>  

<form   name= "form1 "   action= "jinzhan.asp?offset1= <%=offset1%> "   method= "post ">
<INPUT   TYPE= "hidden "   name=id   value= <%=newsrecord1( "id ")%> >
<input   type= "hidden "   name= "kaig_time "   value   = " ">

<input   type= "submit "   value= "修改 "   name   =   "xiugai "   onclick= "return   chk(); ">  

</form>

jinzhan.asp用request( "kaig_time ")怎么都获取不到kaig_time的值,不知道什么原因???
随便问一下,使用户在执行对话框时,选择取消按钮之后,不继续执行下面的语句,是不是只能用InputQuery函数???

------解决方案--------------------
document.form1.kaig_time = CDate(chk)

这个改成document.form1.kaig_time = chk;

input元素只接受字符类型,你只能在服务器端获取后进行数据类型转换
------解决方案--------------------
你写错了,肯定得不到值

document.form1.kaig_time = CDate(chk)
改为:
document.form1.kaig_time.value = CDate(chk)
------解决方案--------------------
like this
----------------------------
<%Response.Write Request.Form( "kaig_time ")%>
<script language= "VBScript ">
Function form1_onsubmit()
chk = inputbox( "请输入开工日期(如:207-1-23) ", "请输入开工日期 ",date())

if chk=cdate( "00:00:00 ") then
form1_onsubmit=false
else
document.form1.kaig_time.value = chk
end if

End Function
</SCRIPT>


<form name= "form1 " method= "post ">
<INPUT TYPE= "hidden " name=id>
<input type= "hidden " name= "kaig_time " value = " ">
<input type= "submit " value= "修改 " name = "xiugai ">
</form>