vendredi 24 avril 2015

how to make checkbox only appear unchecked but really be checked?

hello all i have a problem with sending a form i have a bunch of checkboxes that form a list of items and permissions in my shop i need to tell which items are either permission on or off the list is populated with only permission on items, the db removes off items from the table. therefore only on items are actually shown in the form. since unchecked checkboxes dont get posted i dont have a way to tell the db if the permission is off or on. my solution is to just change the value of the checkbox and leave it checked, however this could be confusing to some users, can i just put a red x over the checkbox making it appear to be unchecked?? how do i accomplish this?

<div class="checkbox">
              <label>
                <input type="checkbox" checked="checked" value="1" id="product[35][access]" name="product[35][access]">
                test 1                 
              </label>
            </div>
<script>

$(':checkbox').change(function() {
if ($(this).prop("checked")) {
    //do the stuff that you would do when 'checked'
this.value = 1
    return;
}
this.value = 0
//Here do the stuff you want to do when 'unchecked'
}); 




Aucun commentaire:

Enregistrer un commentaire