onclick事件出错

linjitvd 2006-07-31 10:01:50
代码如下:
<%
Sub checkCode()
if code = ReadCode(request.form("formCode")) then
AfterCodeCheck = true
end if
end sub
%>

<input type="text" maxlength="4" name="Code" id="txtCode">
<input type="button" name="OK" onclick="checkCode()" value="OK">

在网页中,当我点击OK按纽时,状态栏提示"网页上有错误". 我不知道哪里出错,请赐教
...全文
210 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lindu 2006-08-02
  • 打赏
  • 举报
回复
checkcode.asp
<%if request.form("code") = "" then
response.redirect "regist.html"
response.end()
end if%>
linjitvd 2006-07-31
  • 打赏
  • 举报
回复
多谢各位回答。但我不明白怎么做才能达到我的要求,我的情况是这样的。

页面(register.html)填写完表单后提交后在checkCode.asp中处理数据。
在checkcode.asp中要求用户输入code,如果符合要求则继续处理下一步。如果不符合就返回到register.html并将提交的输入重新写到网页中。

register.html
<form name="form1" action="checkcode.asp" method="post">
...
<input type="submit" value="submit" name="Submit">
</form>

checkcode.asp
<%
call checkCode()
Sub checkCode()
if code = ReadCode(request.form("formCode")) then
AfterCodeCheck = true
else
返回register.html并将提交的输入写回 //代码怎么写?
end if
end sub
%>
<input type="text" maxlength="4" name="Code" id="txtCode">
<input type="submit" name="OK" value="OK"> //这次提交会使register.html提交的内容取消吗?如果取消了到时怎么写回?
leohuang 2006-07-31
  • 打赏
  • 举报
回复
代码修改如下如下:
<%
if Request("OK")="OK" then call checkCode()

Sub checkCode()
if code = ReadCode(request.form("formCode")) then
AfterCodeCheck = true
end if
end sub
%>

<input type="text" maxlength="4" name="Code" id="txtCode">
<input type="submit" name="OK" value="OK">
jiangsh100 2006-07-31
  • 打赏
  • 举报
回复
先要分清楚客户端跟服务器端的函数
你这样子做是不对的
调用服务器端的函数你可以变相通过一个action来执行,如<a href="?action=add">hhh</a>
onclick="checkCode()" 调用的只是客户端的函数
yousite1 2006-07-31
  • 打赏
  • 举报
回复
<input type="text" maxlength="4" name="Code" id="txtCode">
<input type="button" name="OK" value="OK">
<input type="text" maxlength="4" name="Code" id="txtCode">
<input type="button" name="OK" value="OK">
yousite1 2006-07-31
  • 打赏
  • 举报
回复
楼主怎么区分不清楚asp跟html呢?
一个是动态的一个是静态的,一个在服务器端执行一个在客户端执行。。。
<%
call checkCode()
Sub checkCode()
if code = ReadCode(request.form("formCode")) then
AfterCodeCheck = true
end if
end sub
%>

<input type="text" maxlength="4" name="Code" id="txtCode">
<input type="button" name="OK" onclick="checkCode()" value="OK">
<input type="text" maxlength="4" name="Code" id="txtCode">
<input type="button" name="OK" value="OK">

28,390

社区成员

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

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