PHP - array de combos y textbox

 
Vista:

array de combos y textbox

Publicado por esther (5 intervenciones) el 17/03/2012 12:30:01
Buenos días,

Tengo un array de combos y textbox en php. Lo que quiero es que al seleccionar en el combo me cargue el precio en el texbox del mismo indice. Alguna idea??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?
include ("conexion.php");
?>
<!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" dir="ltr" lang="es" xml:lang="es">
<head>
            <title></title>
 
<script language="javascript">
function cargaprecio(IdSelect){
document.form.precio[].value = IdSelect.substring(11,3000);
 
}
</script>
</head>
<body>
<form name="form" id="form" method="post" action="">
 
<select name="id_aseg_cb[]"  id="id_aseg_cb[]" onchange="cargaprecio(this.value);">
  <option value="0" selected="selected">Seleccione</option>
		<?php
		$query = "select * from pruebas_aseg where id_aseg='35'";
		$results = mysql_query($query);
		while ($rows = mysql_fetch_assoc(@$results))
		{?>
<option value="<?php echo str_pad($rows['id'],11,'0',STR_PAD_LEFT).$rows['precio'];?>"><?php echo $rows['prueba'];?> - <?php echo $rows['precio'];?></option>
 
		<?php
		}?>
		</select>
<input type="text" name="precio[]" id="precio[]"/>
 
<select name="id_aseg_cb[]"  id="id_aseg_cb[]" onchange="cargaprecio(this.value);">
  <option value="0" selected="selected">Seleccione</option>
		<?php
		$query = "select * from pruebas_aseg where id_aseg='35'";
		$results = mysql_query($query);
		while ($rows = mysql_fetch_assoc(@$results))
		{?>
<option value="<?php echo str_pad($rows['id'],11,'0',STR_PAD_LEFT).$rows['precio'];?>"><?php echo $rows['prueba'];?> - <?php echo $rows['precio'];?></option>
 
		<?php
		}?>
		</select>
	<input type="text" name="precio[]" id="precio[]"/>
</form>
</body>
</html>

Muchas gracias ;)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder