Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

devope/cheghost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

32 Commits

Repository files navigation

This library automatically sets 0 value to unchecked checkbox, and 1 for checked. Especially useful for multiple checkboxes with the same name when receiving the form with PHP.

Before

.html

<input name="tasks[]" type="checkbox" checked />
<input name="tasks[]" type="checkbox" />
<input name="tasks[]" type="checkbox" checked />

.php

var_dump($_POST['tasks']);
// Expectation:
// array(2) {
// [0]=>
// string(1) "1"
// [1]=>
// string(0) "0"
// [2]=>
// string(0) "1"
// }
// Reality:
// array(2) {
// [0]=>
// string(1) "1"
// [1]=>
// string(0) "1"
// }

After

.js

cheghost("input[type=checkbox]");

.php

var_dump($_POST['isVisible']);
// Reality:
// array(3) {
// [0]=>
// string(1) "1"
// [1]=>
// string(0) "0"
// [2]=>
// string(0) "1"
// }

About

Helps to deal with values of multiple checkboxes

Resources

Stars

Watchers

Forks

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /