HTML submit multiple values through one check box?

后端 未结 3 1181
梦如初夏
梦如初夏 2021-01-06 03:48

Hello I have a form that allows the user to check as many options as they like and then hit submit. Is there any way to have the input type \'checkbox\' submit more than one

3条回答
  •  长情又很酷
    2021-01-06 04:34

    From your comments, it sounds like you have some JavaScript that handles the data before it's submitted. If that's the case, you can add a data attribute to the checkbox. To use your example, you could call it data-valuetwo.

    
    

    Then, your JavaScript can use getAttribute to retrieve the value in your data-valuetwo attribute and handle it appropriately. It could look something like this:

    var valuetwo = checkbox.getAttribute("data-valuetwo");
    

提交回复
热议问题