Ver Mensaje Individual
  #5 (permalink)  
Antiguo 24/07/2003, 20:45
Avatar de TurKa
TurKa
 
Fecha de Ingreso: enero-2003
Ubicación: Gerli, Avellaneda
Mensajes: 543
Antigüedad: 22 años
Puntos: 4
Aquí te dejo el código modificado, por si a alguien le sirve además.
Fíjate que está comentado, por si las dudas.
Código:
<body bgcolor="#009999">
<script languaje="javascript">   
function guardar() {                              
if (forma1.criterio1.value != "") {
	text = forma1.criterio1.value; // este es el texto que escribe el usuario
	o = forma1.criterio.options.length; // cuenta la cantidad de opciones del select
	forma1.criterio.options[o++] = new Option(text,text,"","");
	// forma1.criterio.options[o++] ==> suma 1 a las opciones actuales
	// new Option(text,text,"",""); ==> crea una nueva opción
	alert("\""+text+"\" ha sido agregado"); // da un mensaje de alerta diciendo que se agregó la opción
	}
}
</script>

<form name="forma1" method="post" action="">
  <table width="100%" border="1" cellspacing="0" cellpadding="0">
    <tr> 
      <td colspan="2"><div align="center"><strong>Ingreso de Datos</strong></div></td>
    </tr>
    <tr> 
      <td width="9%">Criterio:</td>
      <td width="91%"><select name="criterio" id="criterio">
        </select>
      <input type="text" name="criterio1" class="BoxNameAncha" value="nuevo criterio" onClick="this.value=''" size="20">
        <input type="button" name="boton_envio" value="Agregar" onClick="guardar()"></td>
    </tr>
    <tr> 
      <td>Nombre:</td>
      <td><input type="text" name="textfield" size="20"></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="Enviar Datos"></td>
    </tr>
  </table>
</form>
</body>
Saludos!
__________________
Programación LAMP con Scrum y XP
www.eugeniabahit.com.com.ar