vendredi 26 décembre 2014

Show text without alert when no checkbox is cecked

I have this js, but is working just when i delete de "nothing" field, but is ugly in my site if not showme couse i have no checkbox cheked.


js:



setInterval(function(){
section[0].innerHTML = '';
for(var i = 0; i < checkbox.length; i++){
if(checkbox[i].checked){
section[0].innerHTML += checkbox[i].value;
} else {
section[0].innerHTML = 'nothing';
}
}
}, 10);


html



Checked checkbox: <b><section></section></b>


This js is woking fine, but i wanna add nothing field:



setInterval(function(){
section[0].innerHTML = '';
for(var i = 0; i < checkbox.length; i++){
if(checkbox[i].checked){
section[0].innerHTML += checkbox[i].value;
}
}
}, 10);




Aucun commentaire:

Enregistrer un commentaire