elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web (Moderador: #!drvy)
| | |-+  De un select a un input typet='text'
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: De un select a un input typet='text'  (Leído 5,212 veces)
Enigma_Hash

Desconectado Desconectado

Mensajes: 22





Ver Perfil
De un select a un input typet='text'
« en: 10 Abril 2013, 21:17 pm »

Hola me gustaria saber de que forma poddria que segun lo que selecciones en el select se ponga ese texto en el input.


PD: No se si va aqui o en programacion general xDD
Gracias.


« Última modificación: 10 Abril 2013, 21:18 pm por Enigma_Hash » En línea

TrashAmbishion


Desconectado Desconectado

Mensajes: 756


Ver Perfil
Re: De un select a un input typet='text'
« Respuesta #1 en: 10 Abril 2013, 22:50 pm »

Que tal, no esperes que te pongan como se hace trata hacer un poco mas...

Si te digo que para eso te puedes apoyar en javascript todos estos controlos tienen "eventos", buscan en el evento select o click de ese control...

Salu2


En línea

l337*


Desconectado Desconectado

Mensajes: 1.016


I've been thinking...


Ver Perfil
Re: De un select a un input typet='text'
« Respuesta #2 en: 10 Abril 2013, 23:37 pm »

jquery

var valsel = $('#id').val();
$('#idTxt').val(valsel);
En línea

TrashAmbishion


Desconectado Desconectado

Mensajes: 756


Ver Perfil
Re: De un select a un input typet='text'
« Respuesta #3 en: 11 Abril 2013, 00:05 am »

jquery

var valsel = $('#id').val();
$('#idTxt').val(valsel);

Igual tiene que hacer una funcion para cuando se seleccione un elemento del select y entonces vincular ese codigo...

salu2  :rolleyes:
En línea

Phantasy

Desconectado Desconectado

Mensajes: 51


Como siempre, pierde el que mas recibe.


Ver Perfil
Re: De un select a un input typet='text'
« Respuesta #4 en: 11 Abril 2013, 14:14 pm »

No se si lo he entendido bien, creo que pides algo parecido a esto.

Es un ejemplo muy facil, sencillo y rapido.

Código:
<html>
<body>

<select id="provincia" name="provincia" onchange="mostrar();">
<option value="0">Seleccione una provincia</option>
<option value="1">Almería</option>
<option value="2">Málaga</option>
<option value="3">Murcia</option>
<option value="4">Valencia</option>
</select>

<script>

function mostrar(){

var v = "Seleccione una provincia";

if(document.getElementById("provincia").value=="1"){

v="Almeria";

}

if(document.getElementById("provincia").value=="2"){

v="Malaga";

}

if(document.getElementById("provincia").value=="3"){

v="Murcia";

}

if(document.getElementById("provincia").value=="4"){

v="Valencia";

}

document.getElementById("mostrar").value=v;

}

</script>

<input type="text" disabled="disabled" id="mostrar" />

</body>
</html>


Un saludo.
En línea

Enigma_Hash

Desconectado Desconectado

Mensajes: 22





Ver Perfil
Re: De un select a un input typet='text'
« Respuesta #5 en: 11 Abril 2013, 19:34 pm »

Perdon pero eso era la primera parte de la pregunta xD.
Cuando la seleccion del select ya esta en el input como puedo hacer para que busque autaomaticamente?
Nose si hay algun modo de simular las teclas del teclado y que se ejecuten (el input esta con un autocomplete y me gustaria seleccionar la primera opcion sin tener que seleccionar y dandole enter)
E estado buscando durante toda la mañana y no encuentro nada si alguien sabe gracias.

HTML:

Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Mapa</title>
<link rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="js/mapa.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
</head>
<body onload="mostrarmap()">
<div align="center">
      <input name="address" id="address" type="text" size="50" onchange="">
      <input type="button" onclick="limpiar()" value="limpiar busqueda">
      <input type="button" onclick="clearOverlays()" value="borrar marcadores">
      <input type="button" onclick="showmarks()" value="mostrar markers">
      <input type="text" name="lat" id="lat" size="20">
      <input type="text" name="long" id="long" size="20">
</div>
<div id="map"></div>
  <div id="dircat" align="center">
    <select name="select" id="datos" onchange="pasardatos()" size="5">
    <option>Calle Ainz&oacute;n, Zaragoza, Espa&ntilde;a</option>
    <option>Calle Alcalde G&oacute;mez Laguna, Zaragoza, Espa&ntilde;a</option>
    <option>Calle C&aacute;diz, 8, 50004 Zaragoza, Espa&ntilde;a</option>
    <option>Avenida Pablo Gargallo, 50003 Zaragoza, Espa&ntilde;a</option>
    <option>Calle Santa Ines, 50003 Zaragoza, Espa&ntilde;a</option>
    <option>Calle la V&iacute;a, 50009 Zaragoza, Espa&ntilde;a</option>
      </select>
<ul id="check">
      <li>
        <label>Cine</label>
        <input type="checkbox" id="chk1" name="chk1" />
      </li>
      <li>
        <label>Restaurantes</label>
        <input type="checkbox" id="chk2" name="chk2" />
      </li>
      <li>
        <label>gimnasios</label>
        <input type="checkbox" id="chk3" name="chk3" />
      </li>
    </ul>
</div>
</body>
</html>

JS:

Código:
  	    var markersArray = [];
        var map;
        var geocoder;
        var fldAddr;
        var fldLng;
        var fldLat;
function mostrarmap(){
  div = document.getElementById('map');
        fldAddr = document.getElementById("address");
        fldLng = document.getElementById("long");
        fldLat = document.getElementById("lat");
  geocoder = new google.maps.Geocoder();
var zaragoza = new google.maps.LatLng(41.64871420000001, -0.8896260000000211);
var opciones = {
    zoom : 14,
    center: zaragoza,
    disableDefaultUI: true,
    zoomControl: true,
  zoomControlOptions: {
  style: google.maps.ZoomControlStyle.SMALL
  },
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(div, opciones);
google.maps.event.addListener(map, 'click', function(event) {
            addMarker(event.latLng);
  });
        var autocomplete = new google.maps.places.Autocomplete(fldAddr);
        autocomplete.bindTo('bounds', map);
        google.maps.event.addListener(autocomplete, 'place_changed', function() {
  var place = autocomplete.getPlace();
  if (place.geometry.viewport) {
    map.fitBounds(place.geometry.viewport);
}
else {
    map.setCenter(place.geometry.location);
    map.setZoom(17);
    var marker = new google.maps.Marker({
        position: place.geometry.location,
        animation: google.maps.Animation.DROP,
        map: map,
        draggable: true,
           });
        markersArray.push(marker);
        google.maps.event.addListener(marker, "dragend", function() {
var coords = this.getPosition()
fldLat.value = coords.lat();
fldLng.value = coords.lng();
});
    }
  marcarDireccion();
});
}
function marcarDireccion() {
           fldAddr.value = fldAddr.value.trim();
           if (fldAddr.value) {
              fldLat.value = "";
              fldLng.value = "";
              geocoder.geocode({'address': fldAddr.value}, function(results, status) {
                 if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    fldLat.value = results[0].geometry.location.lat();
                    fldLng.value = results[0].geometry.location.lng();
                    var txt = fldAddr.value = results[0].formatted_address;
                    if (txt) {
                       var calleCiudad = txt.split(',', 2);
                       txt = calleCiudad[0].trim() + "\n" + calleCiudad[1].trim() + "\n";
                    }
                    txt += "lat: " + fldLat.value + "\nlng: " + fldLng.value + "\n";
                    map.setZoom(17);
                 }
              });
           }
        }
function clearOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(null);
    }
    markersArray.length=0;
  }
}
function pasardatos(){
var datoseleccionado = document.getElementById("datos").value
fldAddr.value=datoseleccionado;
fldAddr.focus();
}
function limpiar(){
fldAddr.value="";
}
En línea

Enigma_Hash

Desconectado Desconectado

Mensajes: 22





Ver Perfil
Re: De un select a un input typet='text'
« Respuesta #6 en: 12 Abril 2013, 07:45 am »

nadie sabe??
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Input TEXT cambiando de color al click?
Desarrollo Web
MinusFour 4 3,276 Último mensaje 11 Abril 2013, 00:24 am
por l337*
XSS en input text
Nivel Web
tonoan 2 2,811 Último mensaje 24 Agosto 2012, 20:11 pm
por BlackZeroX
De un select a un input typet='text'
Programación General
Enigma_Hash 1 2,054 Último mensaje 10 Abril 2013, 22:15 pm
por Puntoinfinito
onChange deja de funcionar al cambiar un <select> por un <input>
PHP
KateLibby 0 1,791 Último mensaje 4 Junio 2013, 14:00 pm
por KateLibby
[Resuelto] SELECT filtrado por valor en input en mysql
PHP
bgnumis 1 2,817 Último mensaje 31 Diciembre 2014, 11:26 am
por #Aitor
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines