Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/12/2014, 06:39
baditxuk
 
Fecha de Ingreso: enero-2007
Mensajes: 284
Antigüedad: 17 años, 3 meses
Puntos: 1
habilitar y deshabilitar campos y botones

Hola.

Tengo 3 opciones de botón de 50, 100 y 300 y otro de otra cantidad. también tengo un botón de enviar.

o 50 o 100 o 300

o otra cantidad

Lo que quiero hacer es que cuando pinches en 50, 100 o 300 se habilite el botón enviar y que cuando pinches en cantidad se deshabilite el botón. ademas cuando pinchas en otra cantidad tiene que salir un campo de texto.
Una vez que introduces un valor numérico que se habilite el botón enviar y que cuando se borre que se vuelva a deshabilitar.

Os pongo lo que tengo programado:

<script language="javascript" type="text/javascript">

function mostrarReferencia(){
if (document.form.Importe[3].checked == true) {
document.getElementById('desdeotro').style.display ='block';
} else {
document.getElementById('desdeotro').style.display ='none';
}
}

function validarNumeros(e) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
if (tecla==109) return true;
if (tecla==110) return true;
if (tecla==189) return true;
if (e.ctrlKey && tecla==86) { return true};
if (e.ctrlKey && tecla==67) { return true};
if (e.ctrlKey && tecla==88) { return true};
if (tecla>=96 && tecla<=105) { return true;}
patron = /[0-9]/;
te = String.fromCharCode(tecla);
return patron.test(te);
}
</script>

<body>
...
<input name="Importe" type="radio" value="50" id="Importe_0" onclick="mostrarReferencia();" checked>50&euro;
<input name="Importe" type="radio" value="100" id="Importe_1" onclick="mostrarReferencia();">100&euro;
<input name="Importe" type="radio" value="300" id="Importe_2" onclick="mostrarReferencia();">300&euro;

<input name="Importe" type="radio" value="" id="Importe_3" onclick="mostrarReferencia();" >OTRA CANTIDAD

<div id="desdeotro" style="display:none;">
<input name="Importe" size="10" type="text" id="Importe_3" value="" onKeyDown="return validarNumeros(event)">&euro; </div>

<INPUT name="enviar" TYPE="submit" VALUE="Colaborar">

</body>