我在后台查询数据库得到一些值怎么赋值给页面的下拉框
发布网友
发布时间:2022-04-09 15:10
我来回答
共1个回答
热心网友
时间:2022-04-09 16:39
sql="select ygbh,GETNAME(ygbh) as name from lz.db_user where qx='2' and inf ='工程师' and ygbh not in (select userid from lz.flow_task where type='权限剥夺') "
+" and ygbh in (select sendid from lz.flow_history where userid='"+ID+"')";
rt=st.executeQuery(sql);
%>
<body bgcolor=#b0e0e6>
<form action="b_down1.jsp">
<table border="0" align="center" width="664">
<tr>
<td height="2" width="134" class="unnamed1">
<div align="right">剥夺对象:</div>
</td>
<td width="520" height="2">
<select name="shenpi">
<%
int b=0;
while(rt.next()){
if(b==0){
%>
<option value="<%=rt.getString("ygbh")%>" selected="selected"><%=rt.getString("ygbh")%>-<%=rt.getString("name")%></option>
<%
b++; }else{
%>
<option value="<%=rt.getString("ygbh")%>"><%=rt.getString("ygbh")%>-<%=rt.getString("name")%></option>
<%
}
}
rt.close();
%>
</select>
</td>
</tr>
循环给option标签赋值即可,这个是我做过一个实例代码,可以参考下