
Copiar texto de un menu desplegable
Publicado por Gustavo (2 intervenciones) el 27/07/2008 15:43:22
Como puedo hacer, en el siguiente ejemplo, para copiar en el textfield el "texto" que selecciono del menu desplegable ?
Como lo estoy haciendo en el ejemplo, copio el valor numerico pero necesito copiar el texto.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Prueba</title>
</head>
<body>
<script language="JavaScript">
function SelecLinea() {
form1.textfield.value=form1.select.value;
}
</script>
<form id="form1" name="form1" method="post" action="">
<p>
<select name="select" onChange="Javascript:SelecLinea()" >
<option value="0" selected="selected">Seleccione ... </option>
<option value="1">Domingo</option>
<option value="2">Lunes</option>
<option value="3">Martes</option>
<option value="4">Miercoles</option>
<option value="5">Jueves</option>
<option value="6">Viernes</option>
<option value="7">Sabado</option>
</select>
</p>
<p>
<input type="text" name="textfield" />
</p>
</form>
</body>
</html>
Como lo estoy haciendo en el ejemplo, copio el valor numerico pero necesito copiar el texto.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Prueba</title>
</head>
<body>
<script language="JavaScript">
function SelecLinea() {
form1.textfield.value=form1.select.value;
}
</script>
<form id="form1" name="form1" method="post" action="">
<p>
<select name="select" onChange="Javascript:SelecLinea()" >
<option value="0" selected="selected">Seleccione ... </option>
<option value="1">Domingo</option>
<option value="2">Lunes</option>
<option value="3">Martes</option>
<option value="4">Miercoles</option>
<option value="5">Jueves</option>
<option value="6">Viernes</option>
<option value="7">Sabado</option>
</select>
</p>
<p>
<input type="text" name="textfield" />
</p>
</form>
</body>
</html>
Valora esta pregunta


0