qq_24466159
qq_24466159
2016-04-10 07:19

form关于checkbox的键值匹配问题

  • checkbox
    <table align="center">
        <tr>
            <td><input type="checkbox" name="names" value="面包">面包 &nbsp;&nbsp;</td>
            <td><input type="hidden" name="price" value="4">价格:4 &nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>数量:<input class="min" name="" type="button" value="-" />
             <input class="text_box" name="number" type="text" value=<%=commodity.getNumber() %> />
             <input class="add" name="" type="button" value="+" /></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="names" value="葡萄">葡萄&nbsp;&nbsp;</td>
            <td><input type="hidden" name="price" value="12">价格:12 &nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>数量:<input class="min" name="" type="button" value="-" />
             <input class="text_box" name="number" type="text" value=<%=commodity.getNumber() %> />
             <input class="add" name="" type="button" value="+" /></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="names" value="苹果">苹果 &nbsp;&nbsp;</td>
            <td><input type="hidden" name="price" value="3">价格:3 &nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>数量:<input class="min" name="" type="button" value="-" />
             <input class="text_box" name="number" type="text" value=<%=commodity.getNumber() %> />
             <input class="add" name="" type="button" value="+" /></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="names" value="香蕉">香蕉 &nbsp;&nbsp;</td>
            <td><input type="hidden" name="price" value="1">价格:1 &nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>数量:<input class="min" name="" type="button" value="-" />
             <input class="text_box" name="number" type="text" value=<%=commodity.getNumber() %> />
             <input class="add" name="" type="button" value="+" /></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="names" value="白菜">白菜 &nbsp;&nbsp;</td>
            <td><input type="hidden" name="price" value="1">价格:1 &nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>数量:<input class="min" name="" type="button" value="-" />
             <input class="text_box" name="number" type="text" value=<%=commodity.getNumber() %> />
             <input class="add" name="" type="button" value="+" /></td>
        </tr>

        <tr>
        <th><input type="submit" id="" value="提交" onclick="getValue()"/>
        <input type="reset" id="" value="重置"></th>
        </tr>       
    </table>

如果我选择

 <td><input type="checkbox" name="names" value="面包"></td>

那么对应的price和number怎么跟它匹配然后通过form传过去,现在情况是 names传过去了,但是price和number是按顺序传过去 也names不匹配的 谢谢!

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐