打印

[asp] 函数调用问题!

写了这样一个函数
function msg(str,button,title)
response.Write("<script language=vbscript>msgbox "&chr(34)&str&chr(34)&","&button&","&chr(34)&title&chr(34)&"</script>")
end function
希望在别的页面调用它后,点击确定或取消时后能将值返回,例如:
msg "得到一个返回值",1,"标题"
    if msg=vbok then
       ...
    end if
但是不知道怎么传递返回值
请大家帮我想想
你的函数需要改一下:
<%
function msg(str,button,title)
response.Write("<script language=vbscript> ans=msgbox "&chr(34)&str&chr(34)&","&button&","&chr(34)&title&chr(34)&"</script>")
end function
%>
<%call msg(str,button,title)%>
<scritp language=vbscript>
if ans=vbyes then
....
else
....
end if
</script>
说明:弹出信息框的返回值赋给ans, 再判断ans的值做相应操作。
由于弹出信息框是在客户端执行的 ,ans的判断也要在<script>中才行。如果你判断后的操作想在服务器端完成 可以用如下代码试一试
<%call msg(str,button,title)%>
<scritp language=vbscript>
if ans=vbyes then
<%
asp处理语句
%>
else
<%
asp处理语句
%>
end if
</script>
现在改成这样
function msg(str,button,title)
response.Write("<script language=vbscript>ans=msgbox ("&chr(34)&str&chr(34)&","&button&","&chr(34)&title&chr(34)&")</script>")
end function

<%
call msg ("成功",1,"拼了")
%>
<script language="vbscript">
if ans=vbOK then
<%response.Write("iloveyou")%>
else
<%response.Write("ihateyou")%>
end if
</script>
现在能显示弹出对话框,但是单击确定或者是取消后还是没有反映,什么都没有输出
自己顶一下,哪位DX帮忙看一下……

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!
求助……
最后一次求助……

TOP



 提示:您可以先修改部分代码再运行
这个样子是可以用地....看看你生成的代码有虾米区别???
个站交流!开发郁闷期

TOP

恩,的确成功了!
谢谢,但是为什么要用到document才行,在单击确定以后不可以执行ASP代码吗

TOP