Some useful Snippets…

The given code performs the reverse binding of Check-box.

After retrieving the value from some data source and comparing the values of each check-box, it checks the one present in the source.

e.g- The data coming from a User Profile Property after REST call is stored in an array and then each of the value is being matched with the Check-box value and the one updated in USP is marked as Checked in the Check-box.
var variable=[Car Bus Train Airplane ]

var splitvar=variable.toString().split(“,”);

// The splitted value comes out in this form by the use of above split method.

splitvar=[“Car” “Bus” “Train” “Airplane”]

document.getElementById(“cbox”).checked = false;

// Here, cbox is the ID of the check-box which is to be bounded back from a certain Value.

$.each(splitvar, function(i, value) {
$(“input[value='”+value+”‘]”).prop(‘checked’, true);



Hope, this would help you out.

Also, I will update some simple java-scripts performing small operations.

1.To clear the selection of Check-box, use the below one liner code.


2.To update the checked, check-box value.

var allVals = [];
$(‘#cbox :checked’).each(function() {

The cbox states for the ID of the Check-box  and allVals is an empty array storing each selection and pushing into the array allVals.