Menu
I have a checkbox which I use to change form settings before submitting.
“`
$(‘#hidden_form_field’).val( $(‘#checkbox’).is(‘:checked’) );
However, when I submit the form, the value comes through as a string ‘true’ or ‘false’ which evaluates to true every time.
So I’ve changed it to the following but it just seems odd writing if true then true (1) or if false then false (0). Is there a cleaner way or is this just the way it is because jQuery and HTML forms don’t play together nicely?
“`
$(‘#hidden_form_field’).val( $(‘#checkbox’).is(‘:checked’)?1:0 );