asp中动态默认selected
<formname="form3"method="post"action=""><tr><tdalign="right"width="20%"colspan="4"sty...
<form name="form3" method="post" action="">
<tr><td align="right" width="20%" colspan="4" style="padding-top:2px;">
<select style="margin:-3px" name="go" onChange='window.location=form.go.options[form.go.selectedIndex].value'>
<option value="">选择显示方式</option>
<option value="admin_pic.asp?action=pic">显示所有图片</option>
<%sql="select * from piccat"
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
do while not rs2.eof%>
<option value="admin_pic.asp?action=pic&piccat_id=<%=rs2("piccat_id")%>"><%=rs2("piccat_name")%></option>在这个代码下如何能动态默认selected就是选中菜单后显示选中项,不是默认项 展开
<tr><td align="right" width="20%" colspan="4" style="padding-top:2px;">
<select style="margin:-3px" name="go" onChange='window.location=form.go.options[form.go.selectedIndex].value'>
<option value="">选择显示方式</option>
<option value="admin_pic.asp?action=pic">显示所有图片</option>
<%sql="select * from piccat"
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
do while not rs2.eof%>
<option value="admin_pic.asp?action=pic&piccat_id=<%=rs2("piccat_id")%>"><%=rs2("piccat_name")%></option>在这个代码下如何能动态默认selected就是选中菜单后显示选中项,不是默认项 展开
展开全部
先做一个函数:
function object_selected(current_value1,value1)
if current_value1=value1 then
sel_str="selected"
else
sel_str=""
end if
object_selected=sel_str
end function
之后:在用到默认的地方:
<option <%= object_selected(Server.HTMLEncode("参数1"),Server.HTMLEncode(Request("参数2")))%> >中山青旅</option>
参数1与参数2,代入用函数即可。
function object_selected(current_value1,value1)
if current_value1=value1 then
sel_str="selected"
else
sel_str=""
end if
object_selected=sel_str
end function
之后:在用到默认的地方:
<option <%= object_selected(Server.HTMLEncode("参数1"),Server.HTMLEncode(Request("参数2")))%> >中山青旅</option>
参数1与参数2,代入用函数即可。
2013-07-14
展开全部
看看这样行不行:
<select name="select">
<option value="0" <% if 条件 then response.write "selected"%>>XXX</option>
<option value="1" <% if 条件 then response.write "selected"%>>>A</option>
<option value="2" <% if 条件 then response.write "selected"%>>>B</option>
<option value="3" <% if 条件 then response.write "selected"%>>>C</option>
</select>
可根据自己的情况修改。或者是传相对应的条件,在sql语句里加上where语句,看看怎么样
<select name="select">
<option value="0" <% if 条件 then response.write "selected"%>>XXX</option>
<option value="1" <% if 条件 then response.write "selected"%>>>A</option>
<option value="2" <% if 条件 then response.write "selected"%>>>B</option>
<option value="3" <% if 条件 then response.write "selected"%>>>C</option>
</select>
可根据自己的情况修改。或者是传相对应的条件,在sql语句里加上where语句,看看怎么样
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-14
展开全部
<td width="92%" class="table_trbg02">
<select name="years" id="years">
<%
for i=1949 to 2050
if year(date())=i then
response.Write "<option value="&i&" selected=""selected"" >"&i&"</option>"
else
response.Write "<option value="&i&">"&i&"</option>"
end if
next
%>
</select>年
<select name="moths" id="moths">
<% for i=1 to 12
if Month(date())=i then
response.Write "<option value="&i&" selected=""selected"" >"&i&"</option>"
else
response.Write "<option value="&i&">"&i&"</option>"
end if
next
%>
</select>月
<select name="dates" id="dates">
<% for i=1 to 31
if day(date())=i then
response.Write "<option value="&i&" selected=""selected"">"&i&"</option>"
else
response.Write "<option value="&i&">"&i&"</option>"
end if
next
%>
</select>日</td>
<select name="years" id="years">
<%
for i=1949 to 2050
if year(date())=i then
response.Write "<option value="&i&" selected=""selected"" >"&i&"</option>"
else
response.Write "<option value="&i&">"&i&"</option>"
end if
next
%>
</select>年
<select name="moths" id="moths">
<% for i=1 to 12
if Month(date())=i then
response.Write "<option value="&i&" selected=""selected"" >"&i&"</option>"
else
response.Write "<option value="&i&">"&i&"</option>"
end if
next
%>
</select>月
<select name="dates" id="dates">
<% for i=1 to 31
if day(date())=i then
response.Write "<option value="&i&" selected=""selected"">"&i&"</option>"
else
response.Write "<option value="&i&">"&i&"</option>"
end if
next
%>
</select>日</td>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询