使用复选框发送多个值

时间:2011-05-16 06:18:19

标签: java jsp servlets

我已经创建了一个表,其中一个表列是一个复选框和其他数据  现在我知道如何使用复选框发布单个值bt如何发送整行 即,当用户检查复选框id,标题,描述....... req数量被发布到servlet

<table border="1" cellpadding="6" cellspacing="4" 
       style="border-collapse: collapse" width="200%" id="AutoNumber1"
       align="center" bordercolorlight="#800000" bordercolordark="#800000 " class="left" >
     <tr>
         <td width="5%" align="center">
           <input type="checkbox" id=checked" value=<%= id%>/>
           <font face="Arial" size="3" color="light blue">
             Options</font>
       </td>
       <td width="15%" align="center">
         <font face="Arial" size="3" color="light blue">
          Title</font>
       </td>
       <td width="40%" align="center">
         <font face="Arial" size="3" color="light blue">
          Description</font>
       </td>

              <td width="15%" align="center">
         <font face="Arial" size="3" color="light blue">
          Company</font>
       </td>
      <td width="10%" align="center">
         <font face="Arial" size="3" color="light blue">
          Province</font>
       </td>
            <td width="10%" align="center">
         <font face="Arial" size="3" color="light blue">
          District</font>
       </td>
            <td width="10%" align="center">
         <font face="Arial" size="3" color="light blue">
          Actual Quantity</font>
                 </td>
        <td width="10%" align="center">
         <font face="Arial" size="3" color="light blue">
          Required Quantity</font>

        </td>
    </tr>
</table>

1 个答案:

答案 0 :(得分:0)

在servlet中检查选择了哪个checkbox,并根据该进程检查所有其他数据。例如,如果你的HTML看起来像这样:

<table border="1" cellpadding="6" cellspacing="4" 
       style="border-collapse: collapse" width="200%" id="AutoNumber1"
       align="center" bordercolorlight="#800000" bordercolordark="#800000 " class="left" >
     <tr>
         <td width="5%" align="center">
           <input type="checkbox" id="checkbox_1" value=<%= id%>/>
           <font face="Arial" size="3" color="light blue">
             Options1</font>
       </td>
       <td width="15%" align="center">
         <font face="Arial" size="3" color="light blue">
          Title</font><input id="title_1" />
       </td>
       <td width="40%" align="center">
         <font face="Arial" size="3" color="light blue">
          Description</font><input id="description_1" />
       </td>

    </tr>
         <tr>
         <td width="5%" align="center">
           <input type="checkbox" id="checkbox_2" value=<%= id%>/>
           <font face="Arial" size="3" color="light blue">
             Options2</font>
       </td>
       <td width="15%" align="center">
         <font face="Arial" size="3" color="light blue">
          Title</font><input id="title_2" />
       </td>
       <td width="40%" align="center">
         <font face="Arial" size="3" color="light blue">
          Description</font><input id="description_2" />
       </td>

    </tr>
</table>

比在servlet中,检查是否选择了checkbox_1?如果是,则处理title_1description_1。并为checkbox_2title_2&amp;采用相同的逻辑description_2