How to POST empty <select .. multiple> HTML elements if empty?

后端 未结 8 1856
醉酒成梦
醉酒成梦 2021-02-18 18:09

I have the following multi-select box in a HTML form, where user can select one or more option.


                        
    
提交评论

  • 2021-02-18 19:09

    Include <input type="hidden" name="yourfield" value="" /> to your form where the name is the same as for your multiple="multiple" select.


    It is unfortunate that browsers do not send empty form parameters for multiple="multiple" selects like they do for non-multiple selects or a normal inputs.

    Using a dummy value as proposed in the accepted answer is not a very clean solution.

    (This question has nothing to do with jQuery)

    0 讨论(0)
  • 提交回复
    热议问题