Por ejemplo
Código PHP:
<SCRIPT LANGUAGE="JavaScript">
function marcaTodos(formu) {
for (i=0; i<formu.length; i++) {
with (formu.elements[i]) {
if(className!='fieldset')
if ( type == 'checkbox' ) { checked = true }
}
}
}
function invierte(formu) {
for (i=0; i<formu.length; i++) {
with (formu.elements[i]) {
if(className!='fieldset')
if ( type == 'checkbox' ) { checked = !checked }
}
}
}
</script>
<SCRIPT LANGUAJE="JavaScript">
function habilitaDeshabilita(form) {
if(form.R1[0].checked == true) {
form.D1.disabled = true;
form.Bot1.disabled = true;
form.Bot2.disabled = true;
ele=form.elements;
for(i=0;i<ele.length;i++)
if(ele[i].type=='checkbox')
ele[i].disabled=form.R1[0].checked;
}
else {
form.D1.disabled = false;
form.Bot1.disabled = false;
form.Bot2.disabled = false;
ele=form.elements;
for(i=0;i<ele.length;i++)
if(ele[i].type=='checkbox')
ele[i].disabled=form.R1[0].checked;
}
}
</SCRIPT>
<FORM NAME=formulario>
<input type="radio" value="Manual" name="R1" onClick="habilitaDeshabilita(this.form)">Manual
<input type="radio" value="Automatico" checked name="R1" onClick="habilitaDeshabilita(this.form)">Automatico
<select size="1" name="D1">
<option> </option>
<option>I = Indistinto </option>
<option>C2 = Conjunto de a 2 </option>
<option>C3 = Conjunto de a 3 </option>
<option>CD = Conjunto Dinamico </option>
</select>
<input type="checkbox" name="cod1" value="ON">
<input type="checkbox" name="cod2" value="ON">
<input type="checkbox" name="cod3" value="ON">
<input type="checkbox" name="cod4" value="ON">
<input type="button" name="Bot1" value=" Todos " onClick="marcaTodos(this.form)" style="font-size: 8 pt">
<input type="button" name="Bot2" value="Invertir" onClick="invierte(this.form)" style="font-size: 8 pt">
</FORM>