Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/08/2007, 08:20
Avatar de derkenuke
derkenuke
Colaborador
 
Fecha de Ingreso: octubre-2003
Ubicación: self.location.href
Mensajes: 2.665
Antigüedad: 20 años, 6 meses
Puntos: 45
Re: Agregar datos a un objeto select

Hola Snd234:

En las FAQ tienes muy fácil cómo crear options de un select. Hay una funcioncilla muy cómoda.

De todas maneras, se podría hacer por ejemplo así:
Código PHP:
<input type="text" id="laCaja"
<
button onclick="addOpt( $('elSelect'), $('laCaja').value )">Agrega >> </button>
<
br/>
<
select id="elSelect" size="10">
    <
option value="uno">uno</option>
</
select>

<
script type="text/javascript">
function $(
x) { return document.getElementById(x); }

function 
addOpt(oCntrlsTxt){
    var 
sVal sTxt;
    var 
selOpcion = new Option(sTxtsVal);
    var 
iPos oCntrl.options.length;
    
oCntrl.options[iPos] = selOpcion;
}
</script> 

Un saludo.
__________________
- Haz preguntas inteligentes, y obtendrás más y mejores respuestas.
- Antes de postearlo Inténtalo y Búscalo.
- Escribe correctamente tus mensajes.