JS+ASP 问题有点复杂

a040liutao 2004-12-17 05:14:08
ASP函数postmail()如下
function postmail()
....发信
if 成功 then
postmail="发信成功"
else
postmail="发信失败"
end function

然后我在一个button的onclick时间里调用JS函数 post();
function post(){
alert("<%=postmail()%>");
}
我要点过button才会执行发信 但是
页面在载入时就执行了postmail()

因为JS要在客户端解释 所以alert("<%=postmail()%>");要被解释就要执行postmail()

我需要页面载入时不发信 点BUTTON后才发信 大家讨论下怎么解决

...全文
158 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ScentedTea 2005-03-04
  • 打赏
  • 举报
回复
哦,再说一下吧
把发信操作放到另一页面去,就OK了
ScentedTea 2005-03-04
  • 打赏
  • 举报
回复
我的方法好用吧,呵呵,放分吧
cao8208 2004-12-20
  • 打赏
  • 举报
回复
肯定好用
cao8208 2004-12-20
  • 打赏
  • 举报
回复
<%
function postmail(sendflag)
if sendflag=1 then
'send mail
if sendaccess then
postmail="sendaccess"
'response.write postmail
'response.end
else
postmail="sendfaled"
'response.write postmail
'response.end
end if
else
postmail="notsend"
end if

end function
%>
<script Language="JavaScript">
function post(){
alert("<%=postmail(1)%>");
}
</script>
masm_silly 2004-12-20
  • 打赏
  • 举报
回复
写成过程:
sub postmail()
....发信
if 成功 then
postmail="发信成功"
else
postmail="发信失败"
end if
response.write "<script language=javascript>" & vbcrlf
response.write "function post()" & vbcrlf
response.write "alert(""" &postmail&""");}" &vbcrlf
response.write "</script>"
end sub

调用时:
call postmail()
a040liutao 2004-12-20
  • 打赏
  • 举报
回复
顶一下 怎么没人看看么?
yuqianloveme 2004-12-17
  • 打赏
  • 举报
回复
帮你顶,强烈支持!!
a040liutao 2004-12-17
  • 打赏
  • 举报
回复
ygjwjj(塔克拉玛干---胡杨林)的方法可行
把ASP函数放另外一页去 点button打开并且执行 但我不想那么做
libao1983(★~★~★~李豹--0008号恶搞手--失业中★~★~★~) 如果向你这样的话我什么时候调用函数呢
hackate 2004-12-17
  • 打赏
  • 举报
回复
就是就是!
yqh1314 2004-12-17
  • 打赏
  • 举报
回复
先站个一楼!在说回头帮你看看!
libao1983 2004-12-17
  • 打赏
  • 举报
回复
function postmail()
....发信
if 成功 then
postmail="发信成功"
else
postmail="发信失败"
end if
response.write "<script language=javascript>" & vbcrlf
response.write "function post()" & vbcrlf
response.write "alert(""" &postmail&""");}" &vbcrlf
response.write "</script>"
end function
是不是这样可以解决?你再把问题表述明白一些
ygjwjj 2004-12-17
  • 打赏
  • 举报
回复
把POST()函数写在post.asp中.

<form action="post.asp" method="POST" onsumbit="if(confirm("发信吗?") return true;else return false;">
<input type="sumbit" name="df">
</form>

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧