Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/11/2007, 19:00
svengel
 
Fecha de Ingreso: julio-2007
Ubicación: México DF
Mensajes: 57
Antigüedad: 17 años, 4 meses
Puntos: 4
Re: Como se pueden sumar varios elementos del mismo Array

Muchas Gracias Caricatos funciono a la perfección; para quin le interese aqui pongo el codigo que utilicé:
Saludos
Código PHP:
<script language="JavaScript" type="text/javascript">
<!--
//Relacionamos la seleccion de los menus a una variable.
function alcambiar(){  
  
with(document.formulario){
cp_1 1;
cp_1 += eval(select1.options[select1.selectedIndex].value);
cp_2 0;
cp_2 += eval(select2.options[select2.selectedIndex].value);
if(
cp_1<=cp_2){
alert("Primero debe seleccionar la fecha mas reciente");
}
}
 }
conprorroga = new Array('0''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''3.00''3.00''3.00''3.00''3.00''3.00''3.00''3.00''3.00''3.00''3.00''3.00''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''3.50''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''8.25''6.56''6.56''5.07''4.41''4.32''4.32''4.34''4.50''4.93''5.35''5.27''5.12''5.08''5.32''5.63''5.58''4.13''3.82''4.05''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''1.50''1.50''1.50''1.50''1.50''1.50''1.50''1.50''1.50''1.50''1.50''1.50''1.00''1.00''1.00''1.00''1.00''1.00''1.00''1.00''1.00''1.00''1.00''1.00''1.80''1.40''1.50''1.80''1.80''1.80''1.70''1.50''1.60''1.50''1.2''1.6''2.00''1.07''0.89''1.13''1.50''1.91''1.93''2.00''2.00''1.87''1.56''1.81''2.00''2.00''2.00''2.00''2.00''0.57''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''2.00''1.45''2.00''2.00''2.00''2.00''2.00''2.00''2.00''0.48''0.56''1.08''1.75''1.92''1.67''1.93''1.69''1.69''1.29''1.66''1.65''1.16''0.29''0.81''1.54''1.63''1.69''1.50''1.77''2.00''2.00''2.00''2.00''2.00''1.95''2.00''2.00''1.90''2.00''2.00''2.00''2.00''1.80''1.94''1.49''1.34''0.98''1.38''1.43''1.33''1.62''1.59''1.54''1.53''1.37''1.48''1.48''1.22''1.77''2.00''1.53''1.54''1.61''1.40''1.85''0.85''0.65''1.08''1.03''1.19''0.41''1.48''0.86''0.69''1.11''0.88''1.07''0.92''0.76''0.95''1.34''1.43''1.29''1.38''1.41''1.31''1.17''1.07''1.03''1.01''1.01''0.99''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0.75''0')
function 
calcular1(){
// Se extrae un nuevo Array en base al rango seleccionado en los menus.
sumatorio conprorroga.slice(cp_2,cp_1);
sumatorio2 sumatorio.reverse();
//Introduciomos el String "+" entre cada valor del nuevo array para luego evaluarlo con eval.
res = eval(sumatorio2.join("+"));
//Redondeamos el resultado de la operacion
var flot=parseFloat(res);
var 
resultadoRedondeo=Math.round(flot*10000)/10000 ;
//Imprimimos el resultado en la casilla correspondiente.
document.formulario.resultado1.value=resultadoRedondeo "%";
 }
</script>