急!如何在网页里让别人单项选择获知网站的方式?

Sophia_Sun 2006-11-11 11:46:42
我想在网页里让别人单项选择获知网站的方式,具体内容如下(部分):
Search Engine O Google O Yahoo O Other ______
O Magazine ______
O Expo ______

""______""代表的是输入框.如果选择了"Other"", ""Magazine"" 或者"Expo""就必须在左边输入框里填写具体内容.

我写的ASP代码如下,但结果是:如果别人不选,就会有提示框弹出来;如果选了"Other"", ""Magazine"" 或者"Expo"",不填写左边的详细内容却不会有提示框弹出来.
我的目的是在上面两种情况下都有提示.
注明:
1)单选项的name=""Channel"" type=""radio""
2)输入框的name=""Ch_Detail"" type=""text""
3)单选项"Other""的value=""Other:"";单选项"Magazine""的value=""Magazine:"";单选项""Expo""的value=""Expo:""

ASP 代码:
<%
......
theknown=trim(request(""Channel"")) '单选项的name=""Channel"" type=""radio""
thechanneldetail=trim(request(""Ch_Detail"")) '输入框的name=""Ch_Detail"" type=""text""
if theknown="""" then
response.write""<SCRIPT language=JavaScript>alert('How did you get to know our site?');""
response.write""javascript:history.go(-1)</SCRIPT>""
response.end
end if

if theknown=""Other:"" or theknown=""Magazine:"" or theknown=""Expo:"" then
if thechanneldetail="""" then
response.write""<SCRIPT language=JavaScript>alert('How did you get to know our site?');""
response.write""javascript:history.go(-1)</SCRIPT>""
response.end
end if
end if

......
%>

请各位大侠帮忙看看该怎么写代码?非常感谢.
...全文
235 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chaoliu1 2006-11-13
  • 打赏
  • 举报
回复
单选按钮、输入框,都是提交答案用的。 你最终只用一次数据啊。

因为单选按钮用asp判断,就要判断3次。所以只接用asp获取输入框就好了。

你怕用户不填写,就用JS自动帮用户填吧。反正选了还要填,多此一举
Sophia_Sun 2006-11-13
  • 打赏
  • 举报
回复
有没有人可以帮我啊?
这里不是很多高手的么?分可以再加!!!
icefire988 2006-11-13
  • 打赏
  • 举报
回复
服务器端验证
<%
styles = request.Form("styles")
other = request.Form("other")
magazine = request.Form("magazine")
expo = request.Form("expo")

if styles = "other" and other ="" then response.Write("<script>alert('请输入other');history.go(-1);</script>")
if styles = "magazine" and magazine = "" then response.Write("<script>alert('请输入magazine');history.go(-1);</script>")
if styles = "expo" and expo = "" then response.Write("<script>alert('请输入expo');history.go(-1);</script>")
%>
icefire988 2006-11-13
  • 打赏
  • 举报
回复
客户端验证
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test</title>
<script language="javascript" type="text/javascript">
<!--//
function submit_check()
{
var styles = document.getElementsByName("styles");
//alert(styles);

if(styles[2].checked && document.form1.other.value=="")
{
alert("请填写other");
return false;
}
// else if(styles[2].checked)
// {
// styles[2].value = document.from1.other.value;
// }

if(styles[3].checked && document.form1.magazine.value=="")
{
alert("请填写magazine");
return false;
}
// else if(styles[3].checked)
// {
// styles[3].value = document.from1.magazine.value;
// }

if(styles[4].checked && document.form1.expo.value=="")
{
alert("请填写expo");
return false;
}
// else if(styles[4].checked)
// {
// styles[4].value = document.from1.expo.value;
// }
return true;
}
//-->
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="20061113.asp" onsubmit="return submit_check()">
Search Engine
<label>
<input name="styles" type="radio" value="google" checked="checked" />
</label>
Google
<label>
<input type="radio" name="styles" value="yahoo" />
</label>
Yahoo
<label>
<input type="radio" name="styles" value="other" />
</label>
Other
<label>
<input name="other" type="text" id="other" />
</label>
<br />
<br />
<label>
<input type="radio" name="styles" value="magazine" />
</label>
Magazine
<label>
<input name="magazine" type="text" id="magazine" />
</label>
<br />
<br />
<label>
<input type="radio" name="styles" value="expo" />
</label>
Expo
<label>
<input name="expo" type="text" id="expo" />
</label>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
</form>
</body>
</html>
Sophia_Sun 2006-11-12
  • 打赏
  • 举报
回复
没有人知道怎么用ASP写么?这个页面调用的是一个ASP文件,还有其他的内容要填写,部分用ASP,部分用JS不行的吧?
mingxuan3000 2006-11-11
  • 打赏
  • 举报
回复
js问题
北京不不 2006-11-11
  • 打赏
  • 举报
回复
你就在本页面里用javascript判断吧.就在提交表单按钮上搞个onclick事件.这样是在客户端执行..不用用服务器来运算.
<input type="button" value="提交" onclick="set()">
<script language="javascript">
function set()
{
var va=document.form.Ch_Detail.value
 var ids=document.form.Channel
if(ids[0].checked="checked"||ids[1].checked="checked"||ids[2].checked="checked"&&va!="")
{
this.form.submit
}
else
{
alert("你必须填写")
}
 }
</script>
没调试..如果不能运行。.把if里的=号改成==, !=改成!==很久没写javascript了.请谅解
Sophia_Sun 2006-11-11
  • 打赏
  • 举报
回复
上面的双引号不知道为什么都变成了双双引号,请不要误解,请当作正常的双引号.

28,390

社区成员

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

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