Foros del Web » Programando para Internet » Javascript »

Funcion Multiplicacion

Estas en el tema de Funcion Multiplicacion en el foro de Javascript en Foros del Web. Hola amigos de foros del web tengo la siguiente funcion que multiplica x valores Código: function presta1() { valor3=parseFloat(document.getElementById('val3').value); valor4=parseFloat(document.getElementById('precio').value); document.getElementById('val4').value= valor3 * valor4 ; ...
  #1 (permalink)  
Antiguo 16/06/2010, 12:02
Avatar de yoyoyo82  
Fecha de Ingreso: julio-2009
Ubicación: Springfield
Mensajes: 159
Antigüedad: 14 años, 9 meses
Puntos: 1
De acuerdo Funcion Multiplicacion

Hola amigos de foros del web tengo la siguiente funcion que multiplica x valores

Código:
function presta1()
	{
		valor3=parseFloat(document.getElementById('val3').value);
		valor4=parseFloat(document.getElementById('precio').value);
		
		
	
		document.getElementById('val4').value= valor3 * valor4 ;
		 }
la funcion esta bien, el problema que tengo es que precio lo saco de un array

Código PHP:
<script> 
function componer_Centros(cod_area) 

//alert(cod_area); 
document.miformulario.nombre.length=0;

document.miformulario.unidad.length=0;  
document.miformulario.precio.length=0;  
document.miformulario.nombre.options[0] = new Option("-- Seleccione --","","defaultSelected","");

document.miformulario.unidad.options[0] = new Option("-- Seleccione --","","defaultSelected",""); 
document.miformulario.precio.options[0] = new Option("-- Seleccione --","","defaultSelected",""); 
var indice=1; 
<? 
$sql_depto 
"SELECT * from nom1 inner join un1 on nom1.id=un1.id inner join prec1 on un1.id=prec1.id"
$rs_depto mysql_query($sql_depto$con); 
if(
mysql_num_rows($rs_depto)>0

while(
$row_depto mysql_fetch_assoc($rs_depto)) 


?> 
if(cod_area=='<?=$row_depto["id"]?>') 

document.miformulario.nombre.options[indice] = new Option("<?=$row_depto["nombre"]?>","<?=$row_depto["id"]?>"); 

document.miformulario.unidad.options[indice] = new Option("<?=$row_depto["unidad"]?>","<?=$row_depto["id"]?>"); 
document.miformulario.precio.options[indice] = new Option("<?=$row_depto["precio"]?>","<?=$row_depto["id"]?>"); 

indice++; 

<? 


mysql_close($con); 
?> 




</script>

Este es el resto del codigo
Código PHP:
<? 
$bd_host 
"localhost"
$bd_usuario "root"
$bd_password "yoyoyo"
$bd_base "a+i"
$con mysql_connect($bd_host$bd_usuario$bd_password); 
mysql_select_db($bd_base$con); 
$sql "SELECT * from mat1"
$rs mysql_query($sql$con); 
?> 
 


<select name="clave" id="clave" onChange="componer_Centros(this.value);"> 
<option value="">--Seleccione--</option> 
<? if(mysql_num_rows($rs)>0

while(
$row mysql_fetch_assoc($rs)) 

?> 
<option value="<?=$row["id"]?>"><?=$row["clave"]?></option> 
<? 


?> 
</select>
<select name="nombre" id="nombre">
<option>--seleccione--</option> 
</select>
<select name="unidad" id="unidad"> 
<option>--seleccione--</option> 
</select>
<select name="precio" id="precio"> 
<option>--seleccione--</option> 
</select>
</td>


<td>
Val 2:<input type="text" name="val2" id="val2"/>
</td>
<td>
Val 3:<input type="text" name="val3"  id="val3"/>
<input type="button" value="=" onClick="presta()">
</td>
<td>
Val 4:<input type="text" name="val4"  id="val4"/>
<input type="button" value="=" onClick="presta1()">
</td>
<td>
Que debo hacer para que en la funcion de presta1() me tome el valor de precio que jalo del arrray

Saludos y Gracias

Última edición por yoyoyo82; 16/06/2010 a las 16:06

Etiquetas: funcion, multiplicacion
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:36.