一般的在页面上做个下拉列表框的话 是这样的对吧:
<select name="">
  <option>aaa</option>
  <option>bbb</option>
</select>
这样的是吗?现在就是我在<option></option>这中间的值是通过一个集合得到的,我要在这怎么放在每个option里呢?请高手帮解答下哦 ,谢谢!!!

解决方案 »

  1.   

    <select name="">
    <c:forEach var="li" items="${list}">
    <option>li[0] </option> 
    <option>li[1] </option> 
    ......
    </c:forEach>
    </select>
      

  2.   


    <c:forEach items="${frist}" var="f">
    <option value="${f.dqbm}">
    ${f.dqmc}
    </option>
    </c:forEach>
      

  3.   

    <select id="select1" class="input">
     <c:forEach var="com" items="${typelist}">
       <option value="${com.typeId }"
       <c:if test="${typeIdNum==com.typeId }"> selected</c:if>>
        ${com.typeName}
       </option>
     </c:forEach>
     </select>
      

  4.   

    除了用C标签还有其他的方吗?因为我现在得在JAVA代码里来写,比方说象buf.append("<select><option></option></select>");这样的做法,在这里面不好用c:forEach的吧.555555555怎么解决哦
      

  5.   

    buf.append(" <select> ");
    for(int i=0;i<list.size();i++){
       buf.append(" <option value='id'> ");
       buf.append(value); 
       buf.append(" <option> ");
    }
    buf.append(" </select> ");
      

  6.   

    在JS里组装或者直接在JSP中用for(int i=0; i < list.size(); i++){ 
      out.println(" <select> <option>"list.get(i)" </option> </select>");
      

  7.   

    上面忘了连接符.....
    for(int i=0; i < list.size(); i++){ 
      out.println(" <select> <option>" + list.get(i) + " </option> </select>");
      

  8.   

    document.getElementById("select的name").add(new Option(key,value))
      

  9.   

    <logic:present name="shopList">
      <html:select property="shopName" value="" >
    <html:option value=""></html:option>
    <html:options property="shopName" collection="shopList" labelProperty="shopName"></html:options>
      </html:select>
    </logic:present>可以仿照这个做,shopList是集合,shopName相当于集合元素吧,如果不用Struts标签,直接换过来就行了
      

  10.   

    将下面的东西直接就可以贴到你的JSP页面的相应位置,
    只不过转换成你相应的类,且在页面上引入就可以了<select id="ruleID" name="ruleID" style="width:154px;" onchange="changeEvent(this);">
    <option value="-1">---------请选择--------</option>
    <% 
    List rList1 = (List) request.getSession().getAttribute("ruleName");
    if(rList1!=null&&rList1.size()>0)
    {
    for(int jj=0;jj<rList1.size();jj++)
    {                                 // 转换成你的类
    CardRule cr = (CardRule)rList1.get(jj);
      %>
    <option value="<%=cr.getId() %>" <% if(cr.getId() == ruleID) out.print("selected"); else out.print(cr.getId());%>> <%=cr.getRuleCode() %> </option>
    <%}} %>
    </select>
      

  11.   

    或者直接用Struts 标签也可以,要提前引入标签
    <select name="type"  style="width:154px;">
    <option value="" selected>请选择</option>
    <logic:present name="sfType">//自己request里面set的
      <logic:iterate id="sfTypes" name="sfType">
        <option value='<bean:write name="sfTypes" property="***"/>'><bean:write  name="sfTypes"  property="***"/></option>
      </logic:iterate>
    </logic:present>
    </select>
      

  12.   

    <select>
    <%
    for(int i=1998;i<2018;i++)
    {
    String year=String.valueOf(i);
            %>
              <option value="<%=year%>"><%=year%>年</option>
            <%
    }
    %>
    </select>
      

  13.   

    <html:select property="deptid">
            <c:forEach var="list" items="${deptList}">
    <html:option value="${list.deptid}">
    <c:out value="${list.deptinfoname}"/>
    </html:option> 
    </c:forEach>
    </html:select>     
    参考代码
      

  14.   

    <html:select property="status" styleClass="tselect">
    <html:option value="">全部</html:option>
    <html:optionsCollection name="fundList" label="label" value="id" />
    </html:select>