Ver Mensaje Individual
  #8 (permalink)  
Antiguo 03/03/2006, 12:48
cgpampa
 
Fecha de Ingreso: enero-2003
Mensajes: 25
Antigüedad: 22 años, 3 meses
Puntos: 0
bueno gente.. se va aclarando un poco el camino.. gracias a todos!!
ahora, todo quedo asi:
Código:
<script language="JavaScript1.2"> 
<!--
function aprobPresup(pag){ 
    document.formulario.action= pag 
    document.formulario.submit() 
} 

function habilitarLinea(v) { 
	if (document.getElementById('checkItem_'+ v).checked ) { 
		document.getElementById('moneda_' + v).disabled = false; 
		document.getElementById('cotizacion_' + v).disabled = false; 
		document.getElementById('precio_' + v).disabled = false; 
		CalcularPrecio(v);
	} else { 
		document.getElementById('moneda_' + v).disabled = true; 
		document.getElementById('cotizacion_' + v).disabled = true; 
		document.getElementById('precio_' + v).disabled = true; 
		RestarSubtotal(v);
	} 
}

function CalcularPrecio(v) { 
	var valor1 = document.getElementById('cotizacion_' + v).value;
	var valor2 = document.getElementById('precio_' + v).value;
	var valor3 = document.getElementById('cantidad_' + v).value;
	var sum = (valor1 * valor2 * valor3);
	document.getElementById('subtotal_' + v).value = sum;
	document.getElementById('totalPresup').value = eval(document.getElementById('totalPresup').value) + sum;
}

function RestarSubtotal(v) { 
	var valor1 = document.getElementById('cotizacion_' + v).value;
	var valor2 = document.getElementById('precio_' + v).value;
	var valor3 = document.getElementById('cantidad_' + v).value;
	var sum = (valor1 * valor2 * valor3);
	document.getElementById('subtotal_' + v).value = sum;
	document.getElementById('totalPresup').value = eval(document.getElementById('totalPresup').value) - sum;
}

function SumarCostoEnvio() { 
	document.getElementById('totalPresup').value = eval(document.getElementById('totalPresup').value) + eval(document.getElementById('costoEnvio').value);
}

function RestarCostoEnvio() { 
	document.getElementById('totalPresup').value = eval(document.getElementById('totalPresup').value) - eval(document.getElementById('costoEnvio').value);
	document.getElementById('costoEnvio').value = 0;
	
}
function habilitarCosto() { 
	if (document.getElementById('checkCosto').checked ) { 
		document.getElementById('costoEnvio').disabled = false; 
//		CalcularPrecio(v);
	} else { 
		document.getElementById('costoEnvio').disabled = true; 
		RestarCostoEnvio();
	} 
}

function validarSoloNros(){
	var tecla = window.event.keyCode; 	// codigo de tecla.
	if ((tecla < 46 || tecla > 57) ||  	// si no es numero 
		(tecla == 47 )) {
		window.event.keyCode = 0; 		// anula la entrada de texto.
	}
}

function validardatos(formulario) {
//	var w = <%//=%>;
	for (var w = 0; w < formulario.checkAgItem.length; w++)
		if (formulario.checkAgItem[w].checked == true) {
	}
}

function validar() {
	if (reconfirmar() == true){ //((validardatos() == true) && 
		return true;
	} else {
		return false;
	}
}

function reconfirmar() {
	respuesta = confirm ("Registra el Presupuesto.\n¿Esta seguro?")
       if (respuesta) {     
            return true;
        }
        else {return false; }
}
-->
</script>
y en la parte del codigo html asi:

Código:
                      	for (int x = 0; iter.hasNext(); x++) {
                      	    PresupuestoItem lis = (PresupuestoItem) iter.next();
                      	    Item lis1 = lis.getUnItem();
		                    Producto pr = (Producto) lis1.getProducto();
		                    int cant = lis1.getCantidad();
					        monto = lis1.getProducto().getPrecio() + monto;
			          %>
			              <TR>
					        <TD width=8% colspan="1" rowspan="2" align="center" valign="middle" class="lineaDetalle">
								<input type="checkbox" name="checkItem_<%=x%>" id="checkItem_<%=x%>" value="checkbox" onClick="habilitarLinea(<%=x%>)">
							</TD>			              
					      	<TD width=15% colspan="1" class="lineaDetalle"><%=pr.getRubro()%></TD>
						    <TD width=26% colspan="1" class="lineaDetalle"><%=pr.getNombre()%></TD>
					        <TD width=23% colspan="1" class="lineaDetalle"><%=pr.getDescripcion()%></TD>
					        <TD colspan="2" class="lineaDetalle">
					        	<%=cant%>
					        	<input type="hidden" name="cantidad" id="cantidad_<%=x%>" value="<%=cant%>">
					        </TD>

					     </TR>
						 <TR>
					      	<TD width=15% colspan="1" valign="middle" class="lineaDetalle">Moneda:
                                <select name="moneda" size=1 class="SELECT1" id="moneda_<%=x%>" disabled="enabled">
                                    <option value="Euro">Euro</option>
                                    <option value="Dolar">Dolar</option>
                                    <option value="Peso">Peso</option>
                                </select>
                                <input type="hidden" name="monedagg">
                           </TD>
						    <TD width=26% colspan="1" class="lineaDetalle" align="right">Cotizacion:
                                <input name="cotizacion" id="cotizacion_<%=x%>" value="0" type="text" class="INPUT1" size="10" maxlength="10" onKeypress="validarSoloNros()" disabled="enabled">
                                <input name="cotizaciongg" type="hidden">
                           </TD>
					        <TD width=23% colspan="1" class="lineaDetalle" align="right">Precio:
					            <input name="precio" id="precio_<%=x%>" type="text" class="INPUT1" value="0" size="10" maxlength="10" onKeypress="validarSoloNros()" onblur="CalcularPrecio(<%=x%>)" disabled="enabled">
					            <input name="preciogg" type="hidden">
					       </TD>
					        <TD colspan="2" class="lineaDetalle" align="right">SubTotal: 
					            <input name="subtotal" id="subtotal_<%=x%>" type="text" class="INPUT1" value="0" size="10" maxlength="10" readonly="readonly">
					            <input name="subtotalgg" type="hidden">
					        </TD>
					      </TR>
					   <% } %>
						 <TR>
					      	<TD colspan="3" class="lineaDetalle"><div align="right"><strong class="encabezado1">Costo de Envío:</strong>
					      	        <input type="checkbox" name="checkCosto" id="checkCosto" onclick="habilitarCosto()">
					      	        <input name="costoEnvio" type="text" class="INPUT1" value=0 size="15" maxlength="15" onKeypress="validarSoloNros()" onblur="SumarCostoEnvio()" disabled="enabled">
					      	    </div>
					       </TD>
					 
					      	<TD colspan="2" class="lineaDetalle"><div align="right"><strong class="encabezado1">Importe Total:</strong>
					      	        <input name="totalPresup" id="totalPresup" type="text" class="INPUT1" value=0 size="15" maxlength="15">
					      	    </div></TD>
						    </TR>
                      </TABLE>
el tema ultimo ahora, son en realidad dos cosas..
1.) del lado del servlet, en java, d eque forma tomo los valores cuando tengo que recuperar los valores de la linea? Ya que al ser un SET de productos, estos no vendran ordenados.. en el orden en que se mostraron en la pagina.. AUXILIIIIIIIIOOOO!!!...

2.) Tenia el cursor en precio, y cambie de ventana a otro programa, cuando vengo.. me sumo ese mismo precio al total!!! porque el calculo lo mande a hacer en el onblur.. y despues lo hice a proposito.. y por cada vez que lo hacia.. seguia sumando el muy desgrac....!!!!
como puedo solucionar eso??

gracias a todos por la inmensa ayuda!!
buen fin de semana!!
JP.