真的没有高手能帮我吗?

hnds_zlily 2001-07-11 10:26:56
其实问题很简单,但我刚开始学ASP。
<% Application("filebase") = Server.MapPath("files") & "\" %>


<html>
<head>
<title>淮南市地税局聊天室</title>
<script language="JavaScript">
function verify(form){
if(form.Name.value == ""){
alert("请输入您的姓名!");
}else{
}
</script>
</head>
<body Bgcolor="#476895" TEXT=#f0f0f0>
<%=Request.QueryString("ErrorMessage")%>
<BR>
<center>
<CENTER>
<p><font size="7" color="#FF0000">淮南市地税局聊天室 </font></p>
<p><font size="3" color="#FFFFFF">试用版</font> </p>
<br>
<font face="Trebuchet MS, ms sans serif, Verdana,Arial" size=2 color=#f0f0f0><b>请输入您的姓名进入下面的聊天室!</b>
</center>
<BR>
<BR> <center>
<center>
<form name="form_topics" action="chatroom.asp" method="post" onSubmit="verify(this)">
<table>

<tr>
<td>
<font face="Trebuchet MS, ms sans serif, Verdana,Arial" size=2 color=#f0f0f0>Name:
</td>
<td>
<%
If Not IsNull(Session("Name")) Then
Response.Write "<input type='text' name='Name' value='" & Session("Name") & "' maxlength=12 maxsize=12>"
Else
Response.Write "<input type='text' name='Name' maxlength=12 maxsize=12>"
End If
%>
</td>
</tr><tr>
<td>
<font size=2 face=verdana color=#f0f0f0>Room:
</td>
<td>
<select name="Topic">

<%
Topics = Application("TopicNames")
If IsArray(Topics) Then
For I=1 To UBound(Topics)
Name = Topics(I)
Response.Write "<option value='" & Name & "'>" & Name
Next
End If
%>


</select>
</td>
</tr><tr>
<td colspan=2 align=right>
<div align="center"><br>
<input type="image" src="images/logon.gif" border=0>
</div>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

执行时,若name输入为空,弹出提示输入姓名窗口,确定后,立刻又弹出上一个连接到本窗口的窗口,如何解决?好象就是调用函数verify(this)的问题?
各位大哥帮帮忙。
...全文
100 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tripofdream 2001-07-11
  • 打赏
  • 举报
回复
建议你画个简单的流程看看
hnds_zlily 2001-07-11
  • 打赏
  • 举报
回复
刚才修改还是不对,这样改后当输入为空时,不检验就进入聊天室页面。您能再帮我看看吗?
hnds_zlily 2001-07-11
  • 打赏
  • 举报
回复


这是CHATROOM.ASP的脚本
我找到原因了是因为为空时,重定向到DEFAULP.ASPD页面。<%
If Request("Name") = "" OR Request("Topic") = "" Then
Response.Redirect("default.asp?0")
Else
Topic = FilterTopic(Request("Topic"))
Session("Topic") = Topic
Session("Name") = Request("Name")
End If

Name = Request("Name")
Topic = Request("Topic")

Const BadName = "<font face=verdana size=+1><b>您输入的用户名已经存在,请重新输入。</b></font><br><br>"

If Not IsEmpty(Application("Users")) Then
If IsArray(Application("Users")) Then
uLen = UBound(Application("Users"))
For I = 0 To uLen
If Application("Users")(I) = Name Then
Name = Name & "_1"
Session("Name") = Name
'Response.Redirect("main2.asp?ErrorMessage=" & Server.URLEncode(BadName))
Exit For
End If
Next
Users = Application("Users")
UsersGroup = Application("UsersGroup")
NumOfUsers = UBound(Users)+1
ReDim Preserve Users(NumOfUsers)
ReDim Preserve UsersGroup(NumOfUsers)
'Response.AppendToLog "Number of users when " & Name & " entered: " & NumOfUsers
Users(NumOfUsers-1) = Name
UsersGroup(NumOfUsers-1) = Topic
Application("Users") = Users
Application("UsersGroup") = UsersGroup


UsersIP = Application("UsersIP")
UsersIdleTime = Application("UsersIdleTime")
UsersTimeOn = Application("UsersTimeOn")
ReDim Preserve UsersIP(NumOfUsers)
ReDim Preserve UsersIdleTime(NumOfUsers)
ReDim Preserve UsersTimeOn(NumOfUsers)
UsersTimeOn(NumOfUsers-1) = Now
UsersIdleTime(NumOfUsers-1) = 0
UsersIP(NumOfUsers-1) = Request.ServerVariables("REMOTE_ADDR")
Application("UsersIP") = UsersIP
Application("UsersTimeOn") = UsersTimeOn
Application("UsersIdleTime") = UsersIdleTime
Else
'Response.AppendToLog "Number of users when " & Name & " entered: " & "0 (Not Array)"
ReDim Users(1)
ReDim UsersGroup(1)
Users(0) = Name
UsersGroup(0) = Topic
Application("Users") = Users
Application("UsersGroup") = UsersGroup

Redim UsersIP(1)
Redim UsersIdleTime(1)
Redim UsersTimeOn(1)
UsersTimeOn(0) = Now
UsersIdleTime(0) = 0
UsersIP(0) = Request.ServerVariables("REMOTE_ADDR")
Application("UsersIP") = UsersIP
Application("UsersTimeOn") = UsersTimeOn
Application("UsersIdleTime") = UsersIdleTime

End If
Else
'Initialize Users Variable
Dim NewUsers()
Redim NewUsers(1)
Dim NewUsersGroup()
Redim NewUsersGroup(1)
NewUsers(0) = Name
NewUsersGroup(0) = Topic
Application("Users") = NewUsers
Application("UsersGroup") = NewUsersGroup


Dim NewUsersIP()
Redim NewUsersIP(1)
Dim NewUsersIdleTime()
Redim NewUsersIdleTime(1)
Dim NewUsersTimeOn()
Redim NewUsersTimeOn(1)
NewUsersTimeOn(0) = Now
NewUsersIdleTime(0) = 0
NewUsersIP(0) = Request.ServerVariables("REMOTE_ADDR")
Application("UsersIP") = NewUsersIP
Application("UsersTimeOn") = NewUsersTimeOn
Application("UsersIdleTime") = NewUsersIdleTime
End If
Session("Enter") = True

Function FilterTopic(Topic)
Topic = Replace(Topic, ":", ".")
Topic = Replace(Topic, "/", ".")
Topic = Replace(Topic, "\", ".")
FilterTopic = Topic
End Function

%>

<HTML>
<HEAD>
<TITLE><%=Topic%> Chatroom</TITLE>


</HEAD>
<frameset Framespacing="0" Border="0" Frameborder="0" rows="30,*, 50">
<frame name="chattop" scrolling="no" marginwidth=8 marginheight=0 noresize src="chattop.asp?Topic=<%=Server.URLEncode(Topic)%>" >
<frameset marginwidth="0" merginheight="0" framespacing="0" Border="1" frameborder="1" cols="*,186">
<frame name="chat" scrolling="yes" marginwidth=8 marginheight=0 noresize src="chat.asp">
<frame name="users" scrolling="auto" marginwidth=2 marginheight=0 src="users.asp">
</frameset>
<frame Name="bottom" Src="msg.asp" Marginwidth="0"
Marginheight="0" Framespacing="0" Border="0" Frameborder="NO" scrolling=no>
</frameset>

</frameset>


</HTML>
改成下面就可以了
If Request("Name") <> "" OR Request("Topic") <> "" Then
Topic = FilterTopic(Request("Topic"))
Session("Topic") = Topic
Session("Name") = Request("Name")
End If

hnds_zlily 2001-07-11
  • 打赏
  • 举报
回复
你说的很对,我来检查一下。谢谢您!我该怎么给你加分呢?
typyj 2001-07-11
  • 打赏
  • 举报
回复
对不起
<form name="form_topics" action="chatroom.asp" method="post" onSubmit="verify(this)">
表单发送到的页面chatroom.asp是否正确?
typyj 2001-07-11
  • 打赏
  • 举报
回复
<form name="form_topics" action="chatroom.asp" method="post" onSubmit="verify(this)">
表单发送到的页面chatroom.asp是不正确?

28,391

社区成员

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

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