
关于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是一样的,但是出不了效果,不知道是什么原因?高手能不能解释一下? 展开
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是一样的,但是出不了效果,不知道是什么原因?高手能不能解释一下? 展开
4个回答
展开全部
你先在你要输出的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>")
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>")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%
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>"
%>
四楼用的变量使用的方式确实很好。至于楼主的没出来效果,可能是是使用单双引号的原因吧。
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>"
%>
四楼用的变量使用的方式确实很好。至于楼主的没出来效果,可能是是使用单双引号的原因吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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>")
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>")
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这么写肯定是不行的,方法有很多,给你写个例子
<%
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>"
%>
<%
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>"
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询