关于ASP嵌套的问题

在response.write中如果要加入条件判断要如何写啊?Response.Write("<formname=""Info""action=""admin.asp?a... 在response.write中如果要加入条件判断要如何写啊?

Response.Write("<form name=""Info"" action=""admin.asp?action=setting"" method=""post""><td bgcolor=""#FFFFFF"" align=""left"" height=""48"">禁止注册:<input name=""reglock"" type=""checkbox"" id=""reglock"" value=""1""><input type=""submit"" value="" 确定 ""></td></form>")
我要的效果是如果数据库中是锁定的,就在input中加入checked,即选中状态,如果不是在response.write中,我知道可以这样写:
<form name="Info" action="admin.asp?action=setting" method="post"><td bgcolor="#FFFFFF" align="left" height="48">禁止新用户注册:<input name="reglock" type="checkbox" id="reglock" value="1" <%if rs("lock")=True then%>Checked<%end if%>)><input type="submit" value=" 确定 "></td></form>

就是上面的<%if rs("lock")=True then%>Checked<%end if%> 在response.write中好像不能使用这样嵌套的,有上面办法解决?
目前就1楼的回答可以解决问题,我写的时候,思路跟4楼的mchonline是一样的,但是出不了效果,不知道是什么原因?高手能不能解释一下?
展开
 我来答
linzhaoshi
2010-07-30 · TA获得超过130个赞
知道答主
回答量:117
采纳率:0%
帮助的人:55万
展开全部
你先在你要输出的response.write ""前面把checked付给一个值,如:
if rs("lock")=True then
A="Checked"
end if
然后在你的response.write ""中加如A这个值

Response.Write("<form name='Info' action='admin.asp?action=setting' method='post'><td bgcolor='#FFFFFF' align='left' height='48'>禁止注册:<input name='reglock' type='checkbox' id='reglock' value='1' ><input type='submit' value=' 确定 '"&A&"></td></form>")
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
hongli200078
2010-07-30 · TA获得超过1210个赞
知道小有建树答主
回答量:713
采纳率:0%
帮助的人:1107万
展开全部
<%
if rs("lock")=True then
isChecked = " checked"
else
isChecked = ""
end if
Response.Write "<form name=""Info"" action=""admin.asp?action=setting"" method=""post""><td bgcolor=""#FFFFFF"" align=""left"" height=""48"">禁止注册:<input name=""reglock"" type=""checkbox"" id=""reglock"" value=""1"" "& isChecked &"><input type=""submit"" value="" 确定 ""></td></form>"
%>
四楼用的变量使用的方式确实很好。至于楼主的没出来效果,可能是是使用单双引号的原因吧。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
scheshan
2010-07-30 · TA获得超过1789个赞
知道小有建树答主
回答量:958
采纳率:0%
帮助的人:1296万
展开全部
response.write不能嵌套if语句,你换个思路啊,先做判断,再根据判断结果输出。

Response.Write("<form name=""Info"" action=""admin.asp?action=setting"" method=""post""><td bgcolor=""#FFFFFF"" align=""left"" height=""48"">禁止注册:<input name=""reglock"" type=""checkbox"" id=""reglock"" value=""1"" ")
if rs("lock")=True then response.write("Checked")
response.write("><input type=""submit"" value="" 确定 ""></td></form>")
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友37eb87320
2010-07-30 · TA获得超过1600个赞
知道小有建树答主
回答量:1024
采纳率:0%
帮助的人:1239万
展开全部
你这么写肯定是不行的,方法有很多,给你写个例子

<%
if rs("lock")=True then
isChecked = " checked"
else
isChecked = ""
end if
Response.Write "<form name=""Info"" action=""admin.asp?action=setting"" method=""post""><td bgcolor=""#FFFFFF"" align=""left"" height=""48"">禁止注册:<input name=""reglock"" type=""checkbox"" id=""reglock"" value=""1"" "& isChecked &"><input type=""submit"" value="" 确定 ""></td></form>"
%>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式