繁体   English   中英

如何识别用户选择了哪些?

[英]How can recognize user selected which ones?

我对jsp的请求有两个清单。 第一个是productGroupName,第二个是products。

现在,我将这些显示如下。

<html:form action="/priceOrder"> <table width="100%" id="tableStyle" style="font: message-box;padding: 20px;">
        <logic:iterate id="productGroups" name="productGroup">
        <tr>
            <td>
            <h3 style="background-color: #720D00; color: white;"><bean:write
                name="productGroups" property="prodGroupName" /></h3>
            <table width="100%" id="tableStyle" style="font: message-box; color: white; padding: 20px; background: #F15A00;">
                <tr>
                    <td width="200px"><strong>Product Name</strong></td>
                    <td width="100px"><strong>How Many</strong></td>
                    <td><strong>Info</strong></td>
                </tr>
                <logic:iterate id="product" name="products">
                <tr>
                    <c:if test="${(productGroups.prodGroupID) == (product.prodGroupID)}">
                        <td>
                            <html:checkbox property="productChecked"  ><bean:write name="product" property="prodName"/></html:checkbox>                                 <br />
                        </td>
                        <td><html:text property="quantity" styleId="check"  size="5"/></td>
                        <td><bean:write name="product" property="prodDesc" /></td>
                    </c:if>
                </tr>
                </logic:iterate>
            </table>
            </td>
        </tr>
    </logic:iterate>

        <tr align="center" style="background-color: #F15A00;"><td height="50px">
              <html:submit styleId="buton" property="method"><bean:message key="button.order" /></html:submit>
        </td></tr>
        <tr><td></td></tr>
    </table></html:form>

如您首先看到的,我迭代productGroupNames,显示productGroupName下的productID是否等于productGroupID。 但是我在获取复选框和数量信息时遇到问题。 我需要检查哪种产品以及需要多少种。

我没有做Struts,但是他们的文档至少说您需要<html:multibox>

与其直接进行表单提交,不如通过JS函数提交。 在JS函数中,由于要迭代列表并为复选框和文本字段赋予相同的名称,因此将获得具有相同名称的数组。 那就是您将获得一个ID数组。 您可以获取所选复选框的索引,获取数量,获取对应的列表元素,并使用该值填充单独的隐藏表单变量。 然后提交。

一种替代方法是让每个复选框具有一个隐藏变量,该变量提供列表和复选框之间的某些映射。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM