大悲咒笛子简谱g调:请问asp中如何动态获得列表菜单的初始化值

来源:百度文库 编辑:中科新闻网 时间:2024/05/03 17:12:39
具体是这样的:
源代码如下:
<select class="unnamed2" name="typeid" size="1">
<%
dim rs2,sql2,sel2
set rs2=server.createobject("adodb.recordset")
sql2="select * from type"
rs2.open sql2,conn,1,1
do while not rs2.eof
selected=(rs("type"))
response.write "<option " & selected & " value='"+CStr(rs2("typeID"))+"' name=typeid>"+rs2("type")+"</option>"+chr(13)+chr(10)
rs2.movenext
loop
rs2.close
%></select>
//这里的typeid是自动编号值;type是栏目名称
这些代码可以获得数据库中的栏目名称,但这里没有设定默认菜单项,于是他会自动选中第一项.
请如,当我传递id=<%=rs("newsid")%>到这一页时,我的代码应该怎么写才能把newsid对应的type设为默认?
另外,还有一个问题,希望帮忙解决下:
就是单选按钮如何将外部的变量1或0转换为未选或已选:代码如下
<input name="radiobotton" type="radio">
将此值传入单选按钮:(值:<%=rs("tjnews")%>)
这里的值只有两种情况非1即0,请问如何写?
大哥,能不能用另一种方法,我试了你说的,总是提示语法错误,我想可以用这种,就像这百度知道右上角的如果没登陆就写:“登陆|注册”如果登陆就是“风听雪语 见习魔法师 二级(466) | 我的提问 | 我的回答 | 个人中心 | 退出”
可以用
<%if rs2("typeid")=request("typeid") then %>
selected="selected"
<%else%>
……
<%end if%>
不知道这样的形式行不行,我关键不会用这语法。希望能帮我把代码写出来,我试试看
另外,我认为是不是你的代码里这里有问题?response.write("selected")是不是:response.write(selected="selected")但我这样写出来,语法提示错误。如果这里语法正确的话,不知道客户端能不能读取到selected="selected" 我在这里试了好多次,客户端怎么也读取不到这。哎,我真笨 如果能帮我解决的话,我保证再追加50分,多谢了!

以下直接从我网页上复制的代码:(如果还不行,就加我QQ:76962544,把源代码文件传给你!)
<select name="typeid" id="typeid">
<option selected>请选择类别</option>
<% set rs=createobject("adodb.recordset")
sql="select * from type where typeid=1 or typeid=2"
rs.open sql,conn,1,1
do while not rs.eof%>
<option value="<%=rs("typeid")%>" <% if arttype=rs("typeid") then response.Write("selected")%>><%=rs("typename")%></option>
<%rs.movenext
loop
rs.close%>
</select>

<tr>
<td> </td>
<td>来源:</td>
<td><input name="copyright" type="radio" value="1" <%if artfrom="原创" then response.Write("checked")%>>
原创
<input type="radio" name="copyright" value="2" <%if artfrom<>"原创" then response.Write("checked")%>>
转载
<input name="copyright2" type="text" id="copyright2" <%if artfrom<>"原创" then response.Write("value='"&artfrom&"'")%>></td>
<td> </td>
</tr>

id=request.query("id")
do while not rs2.eof
selected=(rs("type"))
<option value="<%=rs2("typeid")%>" <% if id=rs2("typeid") then response.Write("selected")%>><%=rs2("type")%> </option>
rs2.movenext
loop