java
public static String Option(String str,String str_value,String print_str){
String sel ="<option value="+str_value
if(str.equals(str_value))
sel =sel+" selected"
sel =sel+">"+print_str+"</option>"
return sel
}
String sql = "select id, name _from table "
rs = dbo.Query(sql)
String option = ""
while (rs.next()) {
option = option
+ Comfunc.Option('', rs.getString("id"), rs.getString("name"))}
jsp
<% String option=(String)request.getAttribute("optiondept")%>
<select name="sel" style="width:135">
<%=option%>
</select>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)