使用复选框发送多个值

发布于 2024-11-07 02:56:27 字数 1795 浏览 0 评论 0原文

您好,我创建了一个表,其中一个表列是一个复选框和其他数据 现在我知道如何使用复选框发布单个值 bt 如何发送整行 即当用户选中复选框 id、标题、描述......请求数量被发布到 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>

hi i have created a table one of the table columns is a check box and other data
now i know how i can post a single value with a check box bt how can i send an entire row
i.e. when the user checks the check box id,title,description.......req quantity gets posted to the 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗼ふ静 2024-11-14 02:56:27

在您的 servlet 中检查选中了哪个复选框,并根据该复选框处理所有其他数据。例如,如果您的 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_2title_2 应用相同的逻辑。 description_2

in your servlet check which checkbox are selected and depending upon that process all other data. e.g, if your HTML looks like this:

<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>

than in your servlet, check whether checkbox_1 is selected? if yes than process title_1 and description_1. And apply same logic for checkbox_2, title_2 & description_2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文