![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
28/08/2008, 15:55
|
| | Fecha de Ingreso: septiembre-2003 Ubicación: Merida, yucatan
Mensajes: 282
Antigüedad: 21 años, 5 meses Puntos: 1 | |
Respuesta: problema en evento onchange ventana padre:
<html><head></head><body>
<a href="/mctelecom/codigos/index.php" target="_blank"
onClick="window.open(this.href, this.target,
'width=800,height=700'); return false;"><img
src="imagenes/archivo_004.gif" border=0><br><span
class=estilo13>Insertar Código</span></a>
<p>
<a href="ejemplos/ejemplo1.html">Ejemplo1 -formulario que
esconde campos</a>
<p>
<a href="ejemplos/ejemplo2.html">Ejemplo2 -formulariocon
campos dependientes</a>
<p>
<a href="ejemplos/ejemplo3.html">Ejemplo3 -formulario con
campos dependientes -2</a>
<p>
<a href="ejemplos/ejemplo4.html">Ejemplo4 -formulario con
campos dependientes -2</a>
<p>
<a href="ejemplos/ejemplo5.html">Ejemplo5 -formulario con
campos dependientes -2</a>
<p>
<a href="ejemplos/ejemplo6.html">Ejemplo6 -formulario con
campos dependientes -2</a>
<p>
<a href="ejemplos/ejemplo7.html">Ejemplo7 -formulario con
campos dependientes -2</a>
<form name=frm>
<input type=text id=codigo1 >
<input type=text id=descripcion1>
<input type=text id=precio1>
<input type=text id=cantidad1>
<input type=text id=subtotal1>
<br>
<input type=text id=codigo2>
<input type=text id=descripcion2>
<input type=text id=precio2>
<input type=text id=cantidad2>
<input type=text id=subtotal2>
<br>
<input type=text id=codigo3>
<input type=text id=descripcion3>
<input type=text id=precio3>
<input type=text id=cantidad3>
<input type=text id=subtotal3>
<br>
<input type=text id="TotalP" name="TotalP">
</form>
</body></html>
popup:
<?php
$conexion = mysql_connect('localhost', 'publicida_mc', 'cyberuno'); // se conecta con el servidor
mysql_select_db('publicida_mc', $conexion); // selecciona la base de datos
$tabla2 = mysql_query("SELECT * FROM codigos"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
$indice = 0;
$phpcodigo = array( );
$phpdescripcion = array( );
$phpprecios = array( );
while ($registro = mysql_fetch_array($tabla2)) {
$indice = $indice + 1;
array_push($phpcodigo, $registro['Codigo']);
array_push($phpdescripcion, $registro["Descripcion"]);
array_push($phpprecios, $registro["Precio"]);
} // fin del bucle de ordenes
mysql_free_result($tabla2); // libera los registros de la tabla
?>
<html><head>
<style type="text/css">
.input
{
BORDER-RIGHT: #336699 1px solid;
BORDER-TOP: #336699 1px solid;
FONT-SIZE: 12px;
BORDER-LEFT: #336699 1px solid;
WIDTH: 70;
COLOR: #000000;
BORDER-BOTTOM: #336699 1px solid;
FONT-FAMILY: Arial, Helvetica, sans-serif;
BACKGROUND-COLOR: #679BD0
}
.input2
{
BORDER-RIGHT: #336699 1px solid;
BORDER-TOP: #336699 1px solid;
FONT-SIZE: 12px;
BORDER-LEFT: #336699 1px solid;
WIDTH: 200;
COLOR: #000000;
BORDER-BOTTOM: #336699 1px solid;
FONT-FAMILY: Arial, Helvetica, sans-serif;
BACKGROUND-COLOR: #679BD0
}
.input3
{
BORDER-RIGHT: #336699 1px solid;
BORDER-TOP: #336699 1px solid;
FONT-SIZE: 12px;
BORDER-LEFT: #336699 1px solid;
WIDTH: 60;
COLOR: #000000;
BORDER-BOTTOM: #336699 1px solid;
FONT-FAMILY: Arial, Helvetica, sans-serif;
BACKGROUND-COLOR: #679BD0
}
.input4
{
BORDER-RIGHT: #336699 1px solid;
BORDER-TOP: #336699 1px solid;
FONT-SIZE: 12px;
BORDER-LEFT: #336699 1px solid;
WIDTH: 30;
COLOR: #000000;
BORDER-BOTTOM: #336699 1px solid;
FONT-FAMILY: Arial, Helvetica, sans-serif;
BACKGROUND-COLOR: #679BD0
}
.input5
{
BORDER-RIGHT: #336699 1px solid;
BORDER-TOP: #336699 1px solid;
FONT-SIZE: 12px;
BORDER-LEFT: #336699 1px solid;
WIDTH: 80;
COLOR: #000000;
BORDER-BOTTOM: #336699 1px solid;
FONT-FAMILY: Arial, Helvetica, sans-serif;
BACKGROUND-COLOR: #679BD0
}
</style>
</head><body>
<form name=formu>
<script>
var indice=<? echo $indice;?>;
<?
for($vars=1; $vars<=$indice; $vars++)
{
?>
jscodigo<?php echo $vars; ?> = <?php echo $phpcodigo[$vars-1]; ?>;
jsdescripcion<?php echo $vars; ?> = "<?php echo $phpdescripcion[$vars-1]; ?>";
jsprecios<?php echo $vars; ?> = <?php echo $phpprecios[$vars-1]; ?>;
<?
}
?>
function sumatotal()
{
var sbttl = 0;
for (sumas=1; sumas<=indice; sumas++)
{
if (document.getElementById("subtotal" + sumas).value != "") {
sbttl += parseInt(document.getElementById("subtotal" + sumas).value);
}
}
document.getElementById("total").value = Number(sbttl);
}
function pasarvalor() {
for (cods=1; cods<=indice;cods++) {
opener.frm["cantidad" + cods].value = formu["cantidad" + cods].value;
opener.frm["descripcion" + cods].value = formu["descripcion" + cods].value;
opener.frm["subtotal" + cods].value = formu["subtotal" + cods].value;
}
opener.document.frm["TotalP"].value = formu["total"].value;
}
function cambioinput(vid) {
contenido=document.getElementById("codigo" + vid).value;
for (nums=1; nums<=indice;nums++) {
if (contenido == eval("jscodigo" + nums)) {
document.getElementById("descripcion"+vid).value = eval("jsdescripcion"+nums);
document.getElementById("precio"+vid).value = eval("jsprecios" + nums);
}
}
}
for (num=1; num<=indice;num++)
{
document.write("<input type='text' class='input' id='codigo"+num+"' onchange=\"cambioinput('" + num + "')\"> ");
document.write("<input type='text' class='input2' id='descripcion" + num + "'>");
document.write("<input type='text' class='input3' id='precio" + num + "'>");
document.write("<input type='text' class='input4'id='cantidad"+num+"' onchange=\"document.getElementById('subtotal" + num +
"').value = document.getElementById('precio" + num + "').value * document.getElementById('cantidad" + num + "').value;
sumatotal(); \">;");
document.write("<input type='text' class='input5' id='subtotal" + num + "' ><br>");
}
document.write("<input type='text' name='total' class='input' id='total' ><br>");
</script>
</form>
<a href="JavaScript:close();" title="pasar valor" onclick="pasarvalor()">Regresar a la Ventana Principal</a>
</body></html> |