Do checkbox inputs only post data if they're checked?

后端 未结 12 757
盖世英雄少女心
盖世英雄少女心 2020-11-22 08:04

Is it standard behaviour for browsers to only send the checkbox input value data if it is checked upon form submission?

And if no value data is supplied, is the defa

12条回答
  •  不思量自难忘°
    2020-11-22 08:54

    Having the same problem with unchecked checkboxes that will not be send on forms submit, I came out with a another solution than mirror the checkbox items.

    Getting all unchecked checkboxes with

    var checkboxQueryString;
    
    $form.find ("input[type=\"checkbox\"]:not( \":checked\")" ).each(function( i, e ) {
      checkboxQueryString += "&" + $( e ).attr( "name" ) + "=N"
    });
    

提交回复
热议问题