Ver Mensaje Individual
  #8 (permalink)  
Antiguo 17/04/2009, 13:49
dark_monk9
 
Fecha de Ingreso: mayo-2007
Mensajes: 41
Antigüedad: 17 años
Puntos: 0
Respuesta: Enviar valor seleccionado de un menu lista al codigo de otro

Debido a que de esa forma no funciono, estoy tratando por este lado:

En el "select_numero_obilga" le agregue Onchange: " quitartodos(document.getElementById('select_ficha_ catastral'));insertar(document.getElementById('sel ect_numero_obilga'),document.getElementById('selec t_ficha_catastral'));"

y en <select name="select_ficha_catastral" id="select_ficha_catastral"> borre el codigo que tenia en php.

Añadi el siguiente script en otro lugar

1<script type="text/javascript">

2function conjunto(llave,codigo,nombre){
3 this.id=llave;
4 this.codigo=codigo;
5 this.nombre=nombre;
6}

7var grupo = new Array();
8var cont=0;
9<?php
10 $base_path = "../../";
11 require_once( $base_path . 'configuration.php' );

12 $datos= new Jconfig();
13 $db_host= $datos->host;
14 $db_nombre=$datos->db;
15 $db_user=$datos->user;
16 $db_pass=$datos->password;

17 $conexion= mysql_connect($db_host, $db_user, $db_pass);
18 mysql_select_db($db_nombre,$conexion);

19 $sql="SELECT * FROM inmueble";
20 $rs=mysql_query($sql);
21 $nregistros=mysql_num_rows($rs);

22 if($nregistros > 0){
23 while ($dato = mysql_fetch_array($rs)){
24 echo "grupo[cont++] = new conjunto('".$dato['id_inmueble']."','".$dato['direccion']."','".$dato['ficha_catastral']."');\n";
25 }
26 }
27?>

28function insertar(seleccion1,seleccion2) {
29 for(i=0; i<=seleccion1.options.length-1;i++) {
30 if(seleccion1.options[i].selected) {
31 asignar(seleccion1.options[i].value, seleccion2);
32 break;
33 }
34 }
35}

36function asignar(valor,seleccion) {
37 numelemen = '';
38 numelemen++;
39 seleccion.options.length = numelemen;
40 seleccion.options[numelemen-1].value ='';
41 seleccion.options[numelemen-1].text = 'Seleccione una Ficha';
42 for(i=0;i<=grupo.length-1;i++) {
43 if(grupo[i].id == valor) {
44 numelemen = seleccion.options.length;
45 numelemen++;
46 seleccion.options.length = numelemen;
47 seleccion.options[numelemen-1].value = grupo[i].codigo;
48 seleccion.options[numelemen-1].text = grupo[i].nombre;
49 }
50 }
51}

52function quitartodos(seleccion) {
53 seleccion.options.length=0;
54}
55</script>


Ahora el problema que presento es en la linea 24, ya que a pesar de que no me muestra error, no me esta funcionando y por ende no me esta mostrando los respectivos valores en el "select_ficha_catastral" id="select_ficha_catastral".

La consulta y la conexion a la base de datos estan correctas.

Alguien sabe si estoy comentiendo algun error? muchas gracias a todos!!