Skip to content

html checkbox passing unchecked items to server. Native <input type="checkbox"> does not do it.

Notifications You must be signed in to change notification settings

alfalabs/alfa-checkbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

alfa-checkbox

jquery plugin for checkbox passing checked and unchecked items to server.

Native <input type="checkbox"> in <form> post passes only checked items as string "on". Unchecked items data is lost. It is impossible to uncheck something!
This plugin will pass data for each checkbox as string "true" or "false"

live demo:

alfalabs checkbox demo

dependency: jquery.slim

CSS <style> tag is injected into <head> it can be overriden by user <style> set in <body> with !important; directive
global CSS class name used: alfa-checkbox see example with overriden styles.

how to use:

attach class name to <input> checkbox tag

<input type="checkbox" class="alfa-checkbox" name="nameOfDataField" />

NOTE:
unique name property is required! (needed for posting <form> data and to associate <Label>)
id is set by code id=name

$(document).ready(function () {

	// initialize all checkboxes
    $.alfaCheckbox('.alfa-checkbox', {
		// optional callback function example:
        onChange: function () { formDirty = true; $('button[type=submit]').show(); }
    });

    // to set value of checkbox programmatically:
    $.alfaCheckbox('#id', {set:true});

});

see html example how to use.

About

html checkbox passing unchecked items to server. Native <input type="checkbox"> does not do it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published