Skip to content

Instantly share code, notes, and snippets.

@n1lux
Last active January 13, 2016 19:07
Show Gist options
  • Save n1lux/2c34cf8c09cf933ee19f to your computer and use it in GitHub Desktop.
Save n1lux/2c34cf8c09cf933ee19f to your computer and use it in GitHub Desktop.
checkboxes from json
/********************************************************************
Build checkboxes
params: obj= threat object,
list_all_input = all inputs received,
checkbox_id = checkbox id
type=type data
*********************************************************************/
function build_checkboxes(obj, list_all_input, array_checked_obj, checkbox_id, type_data){
/* Build control types checkboxes */
$(checkbox_id).empty();
var list_checked = [];
var check = ''
$.each(array_checked_obj, function(){
list_checked.push(this.id);
}
);
$.each(list_all_input, function () {
if ($.inArray(this.id, list_checked) == -1){
check = false;
}else{
check = true;
}
$(checkbox_id).append(
$("<div>").addClass("col-lg-4").prepend(
$("<label>").addClass("checkbox-inline i-checks").text(this.name).prepend(
$("<input>").attr({'type':'checkbox', 'name':type_data}).val(this.id).prop('checked', check)
)
)
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment