<td>
     <table id="pointtable" a>
<tr>
    <td >
<%
    for(int l=0;l<buss_list.size();l++)
      {
         HashMap mohm = (HashMap)buss_list.get(l);
  
%>    
<input type="checkbox" id="<%=mohm.get("ID") %>"  value="<%=mohm.get("ID") >" name="moid"/>
                          <%=mohm.get("BNAME") %>&nbsp;&nbsp;   
 <%
     }
        %>

       </td>
   </tr>
    </table>
</td>
RT 遍历出很多chexkbox 怎么样这些checkbox 5个自动换行!谢谢!

解决方案 »

  1.   

    在&nbsp;&nbsp;后面加上<br>标签就换行了 
      

  2.   

    每循环到5的倍数时就用<br>
      

  3.   

    看下出五个的时候td宽度是多少,加上宽度!超过那个宽度就会自动折行!
    否则就判断索引,大于5出br
      

  4.   

    &nbsp;&nbsp;后面加上隐藏得<br>标签,用脚本写在每五个时隐藏得<br>标签显示
      

  5.   

    在每个后面加<br>,或者把<tr><td>一起包起来。
      

  6.   

    你这代码真难看,就不说MVC,你像下面改改也好点。<td>
    <table id="pointtable" a>
    <tr>
    <td>
    <%
    String chkBoxFmt = "<input type='checkbox' id='%s' value='%s' name='moid'/>%s&nbsp;&nbsp;";
    for (int l = 0; l < buss_list.size(); l++) {
    HashMap mohm = (HashMap) buss_list.get(l);
    String id = mohm.get("ID") + "";
    String bname = mohm.get("BNAME") + "";
    out.print(String.format(chkBoxFmt, id, id, bname));
    //每5个换行
    if (l % 5 == 0)
    out.print("<br/>");
    }
    %>
    </td>
    </tr>
    </table>
    </td>
      

  7.   

    if (l % 5 == 0){
    out.print("<br/>");
    }
      

  8.   

    <br> 不妥,我想楼主的意思应该是checkbox都放在<table>中吧。呵呵,我即兴的来一个:
     <td>
         <table id="pointtable">
    <%
    boolean isEnd = false;
    int f = 1;
    for(int l=0;l<buss_list.size();l++)
            { isEnd = false;
                     HashMap mohm = (HashMap)buss_list.get(l);         
    if(l % 5 == 0 && f % 2 == 1) {
       %>
       <tr>
       <%
    } else if(f % 2 == 1) {
    f++;
    }

       %>                   
    <td><input type="checkbox" id="<%=mohm.get("ID") %>"  value="<%=mohm.get("ID") >" name="moid"/><%=mohm.get("BNAME") %></td>                 
          <%
    if(l % 5 == 4 && f % 2 == 0) {
       %>
       </tr>
       <%
    isEnd = true;
    f++;
    }
            }
    if(!isEnd) {
       %>
       </tr>
       <%
    }
    %>
        </table>
    </td>代码没有测试,只是随便写了个思路,可以把任意个数的checkbox以每行5个的形式列在表格里,楼主请享用!