VTolozano
Usuario Novato
Usuario Novato

Les sintetizo la situación: debo sacar un promedio SIEMPRE Y CUANDO  no tenga valores en obs_1 y obs_2.

<script type="text/JavaScript">
 function promedio(){
 var p1=typeof(parseFloat(document.editar.p1.value))=="number"?parseFloat(document.editar.p1.value):0.00;
 var p2=typeof(parseFloat(document.editar.p2.value))=="number"?parseFloat(document.editar.p2.value):0.00;
 var pg=typeof(String(document.editar.pg.value))=="number"?String(document.editar.pg.value):0.00;
 var suma,cuenta,pg,ob1,ob1,nota1,nota2;
 suma=0;
 cuenta=0;
 A='Aprobó';
 NA='NoAprobó';
// tengo que ponerle a cada if un valor 'Aprobó' o 'No Aprobó'
if (obs_1 == 'SC'){
   ob1=99; nota1=A
   } else if (obs_1 == 'RL'){
   ob1=98; nota1=NA
   } else if (obs_1 == 'LP'){
   ob1=97; nota1=NA
   } else if (obs_1 == 'RP'){
   ob1=96; nota1=A
  } else if (obs_1 == 'EQ'){
  ob1=95; nota1=NA
  } else if (obs_1 == 'NA'){
  ob1=94; nota1=A
  }else if (obs_1 == '--'){
 ob1=0; nota1=0
   }  
   document.editar.ob1.value=ob1;
  document.editar.nota1.value=nota1;
 if (obs_2= 'SC'){
 ob2=99; nota2=A
 } else if (obs_2 == 'RL'){
 ob2=98; nota2=NA
 } else if (obs_2 == 'LP'){
 ob2=97; nota2=NA
 } else if (obs_2 == 'RP'){
 ob2=96; nota2=NA
 } else if (obs_2 == 'EQ'){
 ob2=95; nota2=A
 }else if (obs_2 == 'NA'){
 ob1=94; nota1=NA
 }else if (obs_2 == '--'){
 ob2=0; nota2=0
 }  
 document.editar.ob2.value=ob2;
 document.editar.nota2.value=nota2;
// esta parte funciona, es el caso de q no exista valores en las observaciones
 if (ob1 == 0 && ob2 == 0){
  if (p1 > 0) { suma+=p1;
 cuenta+=1
 }
 if (p2 > 0) { suma+=p2;
cuenta+=1
}
if(suma >0){Number(pg =(suma / cuenta));
}
pg=pg*100;
   pg=Math.floor(pg);
   pg=pg/100;
pg = pg.toFixed(2);
document.editar.pg.value=pg;
// y aca es lo que arme para devolver valores pero no se si esta bien o no.
 } else if (nota2=A && p1<> 0 && ob1<90 ){
 return p1
}  else if (nota1=A && p2<> 0 && ob1<90 ){
return p2
} else if (nota1=A && nota2=A ){
return A
} else if (nota1=NA || nota2=NA ){
return NA
}
document.editar.nota2.value=nota2;
</script> 
Le agradezco muchísimo a quien pueda hecharle un vistazo y corregirlo.
Saludos
Victoria

ATENCIÓN: Este tema no tiene actividad desde hace más de 6 MESES,
te recomendamos abrir un nuevo tema en lugar de responder al actual
Opciones:
Ir al subforo:
Permisos:
TU NO PUEDES Escribir nuevos temas
TU NO PUEDES Responder a los temas
TU NO PUEDES Editar tus propios mensajes
TU NO PUEDES Borrar tus propios mensajes
Temas similares
TemaUsuariosRespuestasVisitasActividad
Por: , el 03/Oct/2004, 20:45
p3l1gl20 chavp lick_boy Caos.X143kOct/04
Por: , el 02/May/2009, 06:59
alobo1603 alguienoculto44kMay/09
Por: , el 22/Jul/2008, 03:01
msalmista chavp12kJul/08
Por: , el 18/Ago/2006, 01:11
dix-he-kun User 39066136kAug/06
Por: , el 23/Nov/2005, 18:26
k2erre tunait User 39066152kDec/05