Inside the function, set another variable called "totalChecked" and set it to equal 0. Instead of using "document.form.aceptar.disabled = false;", use "totalChecked = totalChecked + 1;". After the loop, check if totalChecked equals 3. If it does, then use the "document.form.aceptar.disabled = false;" command.
Thank you very much for your help. I think I did it, at least it works the way I want. This is the code:
HTML Code:
<script type="text/javascript">
function enviar(){
document.equipo.aceptar.disabled = true;
var totalchecked=0;
for (i=0;i<document.equipo.elements.length;i++){
if(document.equipo.elements[i].type == "checkbox"){
if(document.equipo.elements[i].checked == 1 ){
totalchecked = totalchecked+1;
}
}
}
if (totalchecked == 3) {
document.equipo.aceptar.disabled = false;
}
}
</script>
What do you think?
Another question... How Can i do to change the style of the button dinamically? If it's disables call class="disabled" and if it's enabled class="enabled".
Buttons in most browsers will become gray, if disabled. If you want something different than the standard, create a class for each state, then change the class name as well as the disabled status.
Bookmarks