Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/07/2013, 08:18
Andrew777
 
Fecha de Ingreso: junio-2009
Ubicación: Bolivia
Mensajes: 96
Antigüedad: 14 años, 10 meses
Puntos: 0
como obtener el valor de un select con php y json y javascripts?

Estimados tengo la siguiente funcion en javascript:
Código Javascript:
Ver original
  1. /*
  2. Fecha: 29/07/2013
  3. Nombre: CrearTipoDestinatario
  4. Objetivo: Obteners los datos de acuerdo al tipo
  5. de destinatario
  6. Parametros: id del select donde se mostrar los datos obtenidos
  7. de acuerdo al tipo de destinatario
  8. */
  9. function CrearTipoDestinatario(id,id_tipo)
  10. {  
  11.     //alert('holas ingreso a la funcion');
  12.     //obtenemos la tabla donde guardaremos a los hijos creados    
  13.     //var tabla =  $('#' + id);
  14.          //alert($('#txTipo').val());        
  15.      //var el = document.getElementById(id_tipo);
  16.      
  17.      //var indice = el.
  18.       //var el  = $('#'+id_tipo);
  19.        //var e = document.getElementById(id_tipo);
  20.        //var indice = document.getElementById(id_tipo).selectedIndex;
  21.       //var valor = document.getElementById(id_tipo);
  22.       var e = document.getElementById(id_tipo);
  23.       var indice = e.options[e.selectedIndex].value;
  24.       alert(indice);
  25.      
  26.        //var dos = e.options[indice].value;
  27.        //alert('holas');
  28.       //alert($("#"+id_tipo).attr("selectedIndex",indice));
  29.      
  30.      
  31.      //var indice  = el.val(1);
  32.       //alert(dos);
  33.      
  34.      //alert($("#txTipo option[value="+ valor +"]").attr("selected",true));
  35.      //alert(el);
  36.      //var indice = el.val();    
  37.      //var indice = el.s
  38.      //alert(indice);
  39.     //var miArray = new Array();
  40.      var miselect = $('#'+id);
  41.     if(indice != 0)
  42.     {
  43.       //miArray[contador] = indice;    
  44.       //ahora creamos el elemento select
  45.       alert('holas amigos');         
  46.       alert(miselect);
  47.      
  48.       $.post("cargar_json_select_destinatarios.php",{tipo:indice},
  49.       function(data) {
  50.                       miselect.empty();
  51.                      //alert('hola select');
  52.                      for (var i=0;i<data.length;i++)
  53.                      {
  54.                         //alert(i);
  55.                         miselect.append('<option value="' + data[i].id + '">' + data[i].literal + '</option>');
  56.    
  57.                      }
  58.                     }, "json");  
  59.        
  60.      }
  61.      else
  62.      {
  63.       miselect.empty();  
  64.       alert("Introduzca el tipo de destinatario");   
  65.      }
  66. }

Cargo datos desde json y jquery y php, sin embargo no me agarra el value del select, revisando el archivo php de json funciona bien, el lio es q no envia el value de javascripts....saludos y gracias