Ahora mismo tengo un codigo como el siguiente:
Código:
Como podeis ver... es muchisimo... y es una 'repeticion' de codigo algo excesiva.... function Disablear(Option, codPreg, chkValue) { switch(codPreg) { case 1: if (Option.value == 1) { document.form_insertar.grpP2_2(0).disabled = false; document.form_insertar.grpP2_2(1).disabled = false; document.form_insertar.grpP2_2(2).disabled = false; document.form_insertar.chkP3_1.disabled = false; document.form_insertar.chkP3_2.disabled = false; document.form_insertar.chkP3_3.disabled = false; document.form_insertar.chkP3_4.disabled = false; document.form_insertar.chkP3_5.disabled = false; document.form_insertar.chkP3_6.disabled = false; document.form_insertar.chkP3_7.disabled = false; document.form_insertar.chkP3_8.disabled = false; document.form_insertar.chkP3_9.disabled = false; document.form_insertar.chkP3_10.disabled = false; document.form_insertar.chkP3_11.disabled = false; document.form_insertar.chkP3_12.disabled = false; document.form_insertar.chkP3_13.disabled = false; document.form_insertar.chkP3_14.disabled = false; document.form_insertar.chkP3_15.disabled = false; document.form_insertar.chkP3_16.disabled = false; document.form_insertar.chkP3_17.disabled = false; document.form_insertar.txtP4_1.disabled = false; document.form_insertar.txtP4_2.disabled = false; document.form_insertar.txtP4_3.disabled = false; document.form_insertar.txtP4_4.disabled = false; document.form_insertar.txtP4_5.disabled = false; document.form_insertar.txtP5_1.disabled = false; document.form_insertar.txtP5_2.disabled = false; document.form_insertar.txtP5_3.disabled = false; document.form_insertar.txtP5_4.disabled = false; document.form_insertar.txtP5_5.disabled = false; document.form_insertar.grpP6(0).disabled = false; document.form_insertar.grpP6(1).disabled = false; document.form_insertar.grpP6(2).disabled = false; document.form_insertar.grpP6(3).disabled = false; document.form_insertar.grpP6(4).disabled = false; document.form_insertar.grpP6(5).disabled = false; document.form_insertar.grpP7(0).disabled = false; document.form_insertar.grpP7(1).disabled = false; document.form_insertar.txtP8_1.disabled = false; document.form_insertar.txtP8_2.disabled = false; document.form_insertar.txtP8_3.disabled = false; document.form_insertar.grpP9(0).disabled = false; document.form_insertar.grpP9(1).disabled = false; document.form_insertar.chkP11_1.disabled = false; document.form_insertar.chkP11_2.disabled = false; document.form_insertar.chkP11_3.disabled = false; document.form_insertar.grpP12(0).disabled = false; document.form_insertar.grpP12(1).disabled = false; } if (Option.value == 2) { document.form_insertar.grpP2_2(0).disabled = true; document.form_insertar.grpP2_2(1).disabled = true; document.form_insertar.grpP2_2(2).disabled = true; document.form_insertar.chkP3_1.disabled = true; document.form_insertar.chkP3_2.disabled = true; document.form_insertar.chkP3_3.disabled = true; document.form_insertar.chkP3_4.disabled = true; document.form_insertar.chkP3_5.disabled = true; document.form_insertar.chkP3_6.disabled = true; document.form_insertar.chkP3_7.disabled = true; document.form_insertar.chkP3_8.disabled = true; document.form_insertar.chkP3_9.disabled = true; document.form_insertar.chkP3_10.disabled = true; document.form_insertar.chkP3_11.disabled = true; document.form_insertar.chkP3_12.disabled = true; document.form_insertar.chkP3_13.disabled = true; document.form_insertar.chkP3_14.disabled = true; document.form_insertar.chkP3_15.disabled = true; document.form_insertar.chkP3_16.disabled = true; document.form_insertar.chkP3_17.disabled = true; document.form_insertar.txtP4_1.disabled = true; document.form_insertar.txtP4_2.disabled = true; document.form_insertar.txtP4_3.disabled = true; document.form_insertar.txtP4_4.disabled = true; document.form_insertar.txtP4_5.disabled = true; document.form_insertar.txtP5_1.disabled = true; document.form_insertar.txtP5_2.disabled = true; document.form_insertar.txtP5_3.disabled = true; document.form_insertar.txtP5_4.disabled = true; document.form_insertar.txtP5_5.disabled = true; document.form_insertar.grpP6(0).disabled = true; document.form_insertar.grpP6(1).disabled = true; document.form_insertar.grpP6(2).disabled = true; document.form_insertar.grpP6(3).disabled = true; document.form_insertar.grpP6(4).disabled = true; document.form_insertar.grpP6(5).disabled = true; document.form_insertar.grpP7(0).disabled = true; document.form_insertar.grpP7(1).disabled = true; document.form_insertar.txtP8_1.disabled = true; document.form_insertar.txtP8_2.disabled = true; document.form_insertar.txtP8_3.disabled = true; document.form_insertar.grpP9(0).disabled = true; document.form_insertar.grpP9(1).disabled = true; document.form_insertar.chkP11_1.disabled = true; document.form_insertar.chkP11_2.disabled = true; document.form_insertar.chkP11_3.disabled = true; document.form_insertar.grpP12(0).disabled = true; document.form_insertar.grpP12(1).disabled = true; window.location = "insertar.asp#bot"; } break; case 2: if (Option.value == 1) { document.form_insertar.grpP2_1(0).disabled = false; document.form_insertar.grpP2_1(1).disabled = false; document.form_insertar.grpP2_1(2).disabled = false; document.form_insertar.grpP2_1(3).disabled = false; document.form_insertar.grpP2_1(4).disabled = false; document.form_insertar.grpP2_1(5).disabled = false; document.form_insertar.grpP2_1(6).disabled = false; document.form_insertar.grpP2_1(7).disabled = false; document.form_insertar.grpP2_1(8).disabled = false; } if ((Option.value == 2)||(Option.value == 3)) { document.form_insertar.grpP2_1(0).disabled = true; document.form_insertar.grpP2_1(1).disabled = true; document.form_insertar.grpP2_1(2).disabled = true; document.form_insertar.grpP2_1(3).disabled = true; document.form_insertar.grpP2_1(4).disabled = true; document.form_insertar.grpP2_1(5).disabled = true; document.form_insertar.grpP2_1(6).disabled = true; document.form_insertar.grpP2_1(7).disabled = true; document.form_insertar.grpP2_1(8).disabled = true; } break; case 9: if (Option.value == 1) { document.form_insertar.chkP9_1.disabled = false; document.form_insertar.chkP9_2.disabled = false; document.form_insertar.chkP9_3.disabled = false; document.form_insertar.chkP9_4.disabled = false; document.form_insertar.grpP10_1(0).disabled = false; document.form_insertar.grpP10_1(1).disabled = false; document.form_insertar.grpP10_2(0).disabled = false; document.form_insertar.grpP10_2(1).disabled = false; document.form_insertar.grpP10_3(0).disabled = false; document.form_insertar.grpP10_3(1).disabled = false; document.form_insertar.grpP10_4(0).disabled = false; document.form_insertar.grpP10_4(1).disabled = false; document.form_insertar.grpP10_5(0).disabled = false; document.form_insertar.grpP10_5(1).disabled = false; } if (Option.value == 2) { document.form_insertar.chkP9_1.disabled = true; document.form_insertar.chkP9_2.disabled = true; document.form_insertar.chkP9_3.disabled = true; document.form_insertar.chkP9_4.disabled = true; document.form_insertar.grpP10_1(0).disabled = true; document.form_insertar.grpP10_1(1).disabled = true; document.form_insertar.grpP10_2(0).disabled = true; document.form_insertar.grpP10_2(1).disabled = true; document.form_insertar.grpP10_3(0).disabled = true; document.form_insertar.grpP10_3(1).disabled = true; document.form_insertar.grpP10_4(0).disabled = true; document.form_insertar.grpP10_4(1).disabled = true; document.form_insertar.grpP10_5(0).disabled = true; document.form_insertar.grpP10_5(1).disabled = true; } break; case 11: if((chkValue == 1)||(chkValue == 2)) { document.form_insertar.chkP11_3.checked = false } if(chkValue == 3) { document.form_insertar.chkP11_2.checked = false; document.form_insertar.chkP11_1.checked = false; } break; } }
Mi pregunta es... Hay alguna manera de hacerlo con pocas lineas de codigo? algun metodo... algo?
Muchas gracias ante todo!!!!
Un Saludo