Les paso mi funcion javascript:
Código PHP:
function generaCond(){
var n = document.getElementsByName('beans.idResistencia').length;
var n2 = document.getElementsByName('beans.idValorRqd').length;
var n3 = document.getElementsByName('beans.idEsparcimiento').length;
var n4 = document.getElementsByName('beans.idEstadoLongitud').length;
var n5 = document.getElementsByName('beans.idEstadoSeparacion').length;
var n6 = document.getElementsByName('beans.idEstadoRugosidad').length;
var n7 = document.getElementsByName('beans.idEstadoMeteorizacion').length;
var n8 = document.getElementsByName('beans.idPresenciaAgua').length;
var n9 = document.getElementsByName('beans.idOrientacion').length;
var i;
for (i=0;i<n;i++){
if (document.getElementsByName('beans.idResistencia')[i].checked)
break;
}
var val = '';
if (i != null && i != n){
val = document.getElementsByName('beans.idResistencia')[i].value;
}
for (i=0;i<n2;i++){
if (document.getElementsByName('beans.idValorRqd')[i].checked)
break;
}
var val2 = '';
if (i != null && i != n2){
val2 = document.getElementsByName('beans.idValorRqd')[i].value;
}
for (i=0;i<n3;i++){
if (document.getElementsByName('beans.idEsparcimiento')[i].checked)
break;
}
var val3 = '';
if (i != null && i != n3){
val3 = document.getElementsByName('beans.idEsparcimiento')[i].value;
}
for (i=0;i<n4;i++){
if (document.getElementsByName('beans.idEstadoLongitud')[i].checked)
break;
}
var val4 = '';
if (i != null && i != n4){
val4 = document.getElementsByName('beans.idEstadoLongitud')[i].value;
}
for (i=0;i<n5;i++){
if (document.getElementsByName('beans.idEstadoSeparacion')[i].checked)
break;
}
var val5 = '';
if (i != null && i != n5){
val5 = document.getElementsByName('beans.idEstadoSeparacion')[i].value;
}
for (i=0;i<n6;i++){
if (document.getElementsByName('beans.idEstadoRugosidad')[i].checked)
break;
}
var val6 = '';
if (i != null && i != n6){
val6 = document.getElementsByName('beans.idEstadoRugosidad')[i].value;
}
for (i=0;i<n7;i++){
if (document.getElementsByName('beans.idEstadoMeteorizacion')[i].checked)
break;
}
var val7 = '';
if (i != null && i != n7){
val7 = document.getElementsByName('beans.idEstadoMeteorizacion')[i].value;
}
for (i=0;i<n8;i++){
if (document.getElementsByName('beans.idPresenciaAgua')[i].checked)
break;
}
var val8 = '';
if (i != null && i != n8){
val8 = document.getElementsByName('beans.idPresenciaAgua')[i].value;
}
for (i=0;i<n9;i++){
if (document.getElementsByName('beans.idOrientacion')[i].checked)
break;
}
var val9 = '';
if (i != null && i != n9){
val9 = document.getElementsByName('beans.idOrientacion')[i].value;
}
var calNat = '';
if(val == '1308'){
calNat = 2;
}else if(val == '1309'){
calNat = 4;
}else if(val == '1310'){
calNat = 7;
}else if(val == '1311'){
calNat = 12;
}else if(val == '1312'){
calNat = 15;
}
var calNat2 = '';
if(val2 == '824'){
calNat2 = 3;
}else if(val2 == '825'){
calNat2 = 8;
}else if(val2 == '826'){
calNat2 = 13;
}else if(val2 == '827'){
calNat2 = 17;
}else if(val2 == '828'){
calNat2 = 20;
}
var calNat3 = '';
if(val3 == '829'){
calNat3 = 5;
}else if(val3 == '830'){
calNat3 = 8;
}else if(val3 == '831'){
calNat3 = 10;
}else if(val3 == '832'){
calNat3 = 15;
}else if(val3 == '833'){
calNat3 = 20;
}
var calNat4 = '';
if(val4 == '834'){
calNat4 = 0;
}else if(val4 == '835'){
calNat4 = 1;
}else if(val4 == '836'){
calNat4 = 2;
}else if(val4 == '837'){
calNat4 = 4;
}else if(val4 == '838'){
calNat4 = 6;
}
var calNat5 = '';
if(val5 == '839'){
calNat5 = 0;
}else if(val5 == '840'){
calNat5 = 1;
}else if(val5 == '841'){
calNat5 = 4;
}else if(val5 == '842'){
calNat5 = 5;
}else if(val5 == '843'){
calNat5 = 6;
}
var calNat6 = '';
if(val6 == '844'){
calNat6 = 0;
}else if(val6 == '845'){
calNat6 = 1;
}else if(val6 == '846'){
calNat6 = 3;
}else if(val6 == '847'){
calNat6 = 5;
}else if(val6 == '848'){
calNat6 = 6;
}
var calNat7 = '';
if(val7 == '824'){
calNat7 = 0;
}else if(val7 == '855'){
calNat7 = 1;
}else if(val7 == '856'){
calNat7 = 3;
}else if(val7 == '857'){
calNat7 = 5;
}else if(val7 == '858'){
calNat7 = 6;
}
var calNat8 = '';
if(val8 == '859'){
calNat8 = 0;
}else if(val8 == '860'){
calNat8 = 4;
}else if(val8 == '861'){
calNat8 = 7;
}else if(val8 == '862'){
calNat8 = 10;
}else if(val8 == '863'){
calNat8 = 15;
}
var calNat9 = '';
if(val9 == '864'){
calNat9 = -12;
}else if(val9 == '865'){
calNat9 = -10;
}else if(val9 == '866'){
calNat9 = -5;
}else if(val9 == '867'){
calNat9 = -2;
}else if(val9 == '868'){
calNat9 = 0;
}
var sumNat = (new Number(calNat)+new Number(calNat2)+new Number(calNat3)+new Number(calNat4)+new Number(calNat5)+new Number(calNat6)+new Number(calNat7)+new Number(calNat8)+new Number(calNat9));
alert("calNat: "+calNat+" calNat2: "+calNat2+" calNat3: "+calNat3+" calNat4: "+calNat4+" calNat5: "+calNat5+" calNat6: "+calNat6+" calNat7: "+calNat7+" calNat8: "+calNat8+" calNat9: "+calNat9);
if(calNat != '' && calNat2 != '' && calNat3 != '' && calNat4 != '' && calNat5 != '' && calNat6 != '' && calNat7 != '' && calNat8 != '' && calNat9 != ''){
//alert("sumNat: "+sumNat);
if((new Number(sumNat)) >= 0){
if((new Number(sumNat)) <= 20){
//alert("Entro a Muy inestable");
for (i=0;i<document.getElementsByName('beans.idEstabilidad').length;i++){
document.getElementsByName('beans.idEstabilidad')[0].disabled = false;
document.getElementsByName('beans.idEstabilidad')[0].checked = true;
}
}
}
if((new Number(sumNat)) >= 21){
if((new Number(sumNat)) <= 40){
//alert("Entro a Inestable");
for (i=0;i<document.getElementsByName('beans.idEstabilidad').length;i++){
document.getElementsByName('beans.idEstabilidad')[1].disabled = false;
document.getElementsByName('beans.idEstabilidad')[1].checked = true;
}
}
}
if((new Number(sumNat)) >= 41){
if((new Number(sumNat)) <= 60){
//alert("Entro a Parcialmente estable");
for (i=0;i<document.getElementsByName('beans.idEstabilidad').length;i++){
document.getElementsByName('beans.idEstabilidad')[2].disabled = false;
document.getElementsByName('beans.idEstabilidad')[2].checked = true;
}
}
}
if((new Number(sumNat)) >= 61){
if((new Number(sumNat)) <= 80){
//alert("Entro a Estable");
for (i=0;i<document.getElementsByName('beans.idEstabilidad').length;i++){
document.getElementsByName('beans.idEstabilidad')[3].disabled = false;
document.getElementsByName('beans.idEstabilidad')[3].checked = true;
}
}
}
if((new Number(sumNat)) >= 81){
if((new Number(sumNat)) <= 100){
//alert("Entro a Totalmente estable");
for (i=0;i<document.getElementsByName('beans.idEstabilidad').length;i++){
document.getElementsByName('beans.idEstabilidad')[4].disabled = false;
document.getElementsByName('beans.idEstabilidad')[4].checked = true;
}
}
}
}else{
alert("ELSE .....");
}
}