Asked  7 Months ago    Answers:  5   Viewed   33 times

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 default value always "on"?

Assuming the above is correct, is this consistent behaviour across all browsers?



Yes, standard behaviour is the value is only sent if the checkbox is checked. This typically means you need to have a way of remembering what checkboxes you are expecting on the server side since not all the data comes back from the form.

The default value is always "on", this should be consistent across browsers.

This is covered in the W3C HTML 4 recommendation:

Checkboxes (and radio buttons) are on/off switches that may be toggled by the user. A switch is "on" when the control element's checked attribute is set. When a form is submitted, only "on" checkbox controls can become successful.

Tuesday, June 1, 2021
answered 7 Months ago

you can get all the selected check box values using following code this might be helpful for you

var myArray = [];
var id = "";
var oTable = $("#example").dataTable();
$(".class1:checked", oTable.fnGetNodes()).each(function() {
    if (id != "") {
        id = id + "," + $(this).val();
    } else {
        id = $(this).val();
Wednesday, March 31, 2021
answered 9 Months ago

Right now, there isn't a huge deal between them - maybe there never will be. However, the point is to give the browser-makers the ability to do something special with it, if they want.

Think about <input type="number"> on cellphones, bringing up number pads, or type="email" bringing up a special version of the keyboard, with @ and .com and the rest available.

On a cellphone, search could bring up an internal search applet, if they wanted.

On the other side, it helps current devs with css.

input[type=search]:after { content : url("magnifying-glass.gif"); }
Saturday, September 4, 2021
Samir Sabri
answered 3 Months ago

Set the checkboxes value attribute to true and you will get true in your post value.

Friday, September 24, 2021
answered 2 Months ago

No but you could query the pg_catalog.pg_database table to see if it exists.

Friday, October 8, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :