RE:Colocar Dato en una caja de texto al elegir opc
Hola a todos un favor necesito hacer una web donde al elegir mi producto me muestre el precio del producto en una caja de texto ya logre que me lo mostrara pero en un select y cada que eligo otro selectdeproducto me muestra el precio en los seleccdeprecio. me lo repite en todos lo select de precio
como le hago para que me muestre el precio en la misma fila de la tabla en la que esta mi producto.
este es micodigo por favor ayudenme
de antemano gracias.
deysi
Form1Prueba.php
?
$server="localhost";
$user="root";
$pass="dljidr";
$bd="administracion";
$link=mysql_connect($server,$user,$pass);
mysql_select_db($bd);
function GetAll($sSql, &$RowCount){
global $link;//hace que pueda utilizar la variable $link de afuera en el ambito de la funcion.
//$hQuery = mysql_query($sSql,$link);
$hQuery = mysql_query("SELECT * FROM clientemysql, productomysql WHERE Password ='$_REQUEST[Password]' and clientemysql.Id_Cliente = productomysql.Id_Cliente ");
$RowCount = 0;
//echo $sSql . "<br><br>";
while ($aRow = @mysql_fetch_array($hQuery)){
$RowCount++;
$aRows[] = $aRow;
}
if ($RowCount > 0)
return $aRows;
}
function GetALlClientes(&$c){
$sSql="select * from productomysql";
return GetAll($sSql,$c);
}
function GetOneClientProducts($aid,&$c){
$sSql="select * from productomysqlplus where Id_Producto='$aid'";
return GetAll($sSql,$c);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Forma 1</title>
<script language="javascript">
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (err2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err3) {
req = false;
}
}
}
return req;
}
var http = getXMLHTTPRequest();
function GetProductos(se) {
var myurl = 'form1productosprueba.php';
//myRand = parseInt(Math.random()*999999999999999);
if(se[se.selectedIndex].value!=0){
var modurl = myurl+"?cl="+se[se.selectedIndex].value;
http.open("GET", modurl, true);
http.onreadystatechange = callBackProductos;
http.send(null);
}
}
function callBackProductos() {
if (http.readyState == 4) {
if(http.status == 200) {
document.getElementById('productos').innerHTML = http.responseText;
}
} else {
document.getElementById('productos').innerHTML = '<img src="anim.gif">';
}
}
function alertar(se){
alert(se[se.selectedIndex].value)
}
</script>
<style type="text/css">
<!--
body {
background-image: url(Imagenes/fons.gif);
}
-->
</style></head>
<body>
<div align="center">
<table width="263" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td width="257"> <h2 align="center"><span class="Estilo2"> <font color="#0000FF">Pedidos </font></span></h2>
</td></tr>
</table>
</div>
<form action="pagina_mail.php" method="post"><div align="center">
<table width="200" border="1">
<tr>
<td>jjjjjjjjj</td>
<td> </td>
<td>jjjjjjjjjjjjj</td>
</tr>
<tr>
<td><select name="clientes" onchange="GetProductos(this)">
<option value="0" >--- Seleccione el Cliente ---</option>
<?
$row1=GetALlClientes($c);
for($i=0;$i<$c;$i++){
?>
<option value="<?=$row1[$i]["Id_Producto"]?>" selected="selected">
<?=$row1[$i]["Producto"]?>
</option>
<? } ?>
</select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><select name="select" onchange="GetProductos(this)">
<option value="0" >--- Seleccione el Cliente ---</option>
<?
$row1=GetALlClientes($c);
for($i=0;$i<$c;$i++){
?>
<option value="<?=$row1[$i]["Id_Producto"]?>" selected="selected">
<?=$row1[$i]["Producto"]?>
</option>
<? } ?>
</select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><select name="select2" onchange="GetProductos(this)">
<option value="0" >--- Seleccione el Cliente ---</option>
<?
$row1=GetALlClientes($c);
for($i=0;$i<$c;$i++){
?>
<option value="<?=$row1[$i]["Id_Producto"]?>" selected="selected">
<?=$row1[$i]["Producto"]?>
</option>
<? } ?>
</select></td>
<td><div align="center">
</div></td>
</tr>
</table>
</div>
<div id="productos">
<p align="center">
<input type="submit" name="Submit" value="Enviar" />
</p>
</div>
</form>
<p> </p>
</body>
</html>
y estsa es mi pagina Form1productosPruebas.php
<?
$server="localhost";
$user="root";
$pass="dljidr";
$bd="administracion";
$link=mysql_connect($server,$user,$pass);
mysql_select_db($bd);
//Elige el producto
function GetAll($sSql, &$RowCount){
global $link;//hace que pueda utilizar la variable $link de afuera en el ambito de la funcion.
$hQuery = mysql_query($sSql,$link);
$RowCount = 0;
//echo $sSql . "<br><br>";
while ($aRow = @mysql_fetch_array($hQuery)){
$RowCount++;
$aRows[] = $aRow;
}
if ($RowCount > 0)
return $aRows;
}
function GetOneClientProducts($aid,&$c){
$sSql="select * from productomysqlplus where Id_Producto='$aid'";
return GetAll($sSql,$c);
}
?>
<!-- Aqui fue donde agregue lo de la funcion para el alert ok?-->
<style type="text/css">
<!--
.Estilo2 {color: #000000}
body {
background-image: url(Imagenes/fons.gif);
}
-->
</style>
<div align="center"></div>
<p> </p>
<div align="center">
<table width="426" height="114" border="0">
<tr>
<td width="233" height="34"><h3 align="center"><font color="#0000FF">Productos</font></h3></td>
<td width="164"><h3><font color="#0000FF">Cantidad </font></h3></td>
</tr>
<tr>
<td height="42"><div align="center">
<select name="select1" id="select1" onChange="alertar(this)">
<option value="0" >--- Seleccione un Producto ---</option>
<?
$row1=GetOneClientProducts($_GET["cl"],$c);
for($i=0;$i<$c;$i++){
?>
<option value="<?=$row1[$i]["PrecioPacto"]?>" selected>
<?=$row1[$i]["PrecioPacto"]?>
</option>
<? }?>
</select>
</div></td>
<td><input name="Cantidad1" type="text" id="Cantidad1" />
<?
$row1=GetOneClientProducts($_GET["cl"],$c);
for($i=0;$i<$c;$i++){
?>
<option value="<?=$row1[$i]["PrecioPacto"]?>" selected>
<?=$row1[$i]["PrecioPacto"]?> </option>
<? }?>
</td>
</tr>
<tr>
<td height="21"><select name="select" id="select2" onChange="alertar(this)">
<option value="0" >--- Seleccione un Producto ---</option>
<?
$row1=GetOneClientProducts($_GET["cl"],$c);
for($i=0;$i<$c;$i++){
?>
<option value="<?=$row1[$i]["PrecioPacto"]?>" selected>
<?=$row1[$i]["PrecioPacto"]?>
</option>
<? }?>
</select></td>
<td height="21"> </td>
</tr>
<tr>
<td height="21"><select name="select" id="select2" onChange="alertar(this)">
<option value="0" >--- Seleccione un Producto ---</option>
<?
$row1=GetOneClientProducts($_GET["cl"],$c);
for($i=0;$i<$c;$i++){
?>
<option value="<?=$row1[$i]["PrecioPacto"]?>" selected>
<?=$row1[$i]["PrecioPacto"]?>
</option>
<? }?>
</select></td>
<td height="21"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
</div>
<div align="center"> </div></td>
</tr>
</table>
</div>