jeudi 8 décembre 2016

init. web page with a lot of checkboxes with JavaScript

I have a web page with 64 checkboxes that represent the bits in a 64 bit binary array. I use eight

// Byte 0
$("input:checkbox[name=byte0]:checked").each( function() {
    byte[0] += parseInt( $(this).val() );
});

like this one (value is bit binary value) to read the result from them which is manageable.

But to initialize them all. Is there a better way then to have 64

if ( parseInt( items[0] ) & 0x80 ) {
    $('#byte0_7').prop('checked', true);
}
else {
    $('#byte0_7').prop('checked', false);
}

Aucun commentaire:

Enregistrer un commentaire