Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/03/2016, 16:28
eContento
 
Fecha de Ingreso: junio-2004
Mensajes: 621
Antigüedad: 19 años, 11 meses
Puntos: 25
Respuesta: llenar input dependiente de select con javascript

Vale,
Es que el "this" se refiere al objeto "select".
Hay que acceder al array de opciones del objeto select, con el indice de la opción seleccionada, y obtener su value (o su text)

Sería algo así:
Código Javascript:
Ver original
  1. function estafuncion(inputSelect){
  2.     var indice = inputSelect.selectedIndex;
  3.     var selectedOption = inputSelect.options[indice]
  4.     document.getElementById("idInput").value=selectedOption.text;
  5. }

O en una sóla linea;

Código Javascript:
Ver original
  1. function estafuncion(inputSelect){
  2.     document.getElementById("idInput").value = inputSelect.options[inputSelect.selectedIndex].text;;
  3. }

A ver si ahora, sí que sí.


Un saludo
__________________
eContento
- Mis artículos y tutoriales
- Mis jsfiddles