Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/08/2007, 01:52
Avatar de caricatos
caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años, 10 meses
Puntos: 1284
Re: Cambiar un select por un input al hacer click en la opcion "otros"

Hola:

Un ejemplillo:

Código:
<html>
<head>
<script>
var i = 0;
function tag(id) {
 return document.getElementById(id);
}

function selector(check) {
 tag('datoSelect').style.display = (check.checked) ? "none" : "inline";
 tag('datoText').style.display = (!check.checked) ? "none" : "inline";
 tag('datoSelect').disabled = check.checked;
 tag('datoText').disabled = !check.checked;
 i = check.checked ? 1 : 0;
}
</script>
</head>
<body>
<form action="javascript: alert(document.forms[0].dato[i].value)" method="get">
<select style="display: inline; width: 300px" name="dato" id="datoSelect">
<option value="dato select 1">select 1</option>
<option value="dato select 2">select 2</option>
<option value="dato select 3">select 3</option>
</select>
<input type="text" name="dato" disabled id="datoText" style="display: none; width: 300px" />
<label for="otro" >otro</label>
<input type="checkbox" id="otro" onclick="selector(this)" />
<button type="submit">ver</button>
</form>
</body>
</html>
Saludos
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo