Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/04/2014, 19:05
Avatar de Briss
Briss
 
Fecha de Ingreso: junio-2011
Mensajes: 1.293
Antigüedad: 12 años, 9 meses
Puntos: 12
Funcion en form

Hola a todos tengo esta funcion que lo que hace es lo siguiente si en tipo tengo Ninguno mi select1 estara deshabilitado... si marco Uno se habilita.... funciona perfecto pero al meterlo dentro de <form> deja de funcionar lei debo usar onsubmit="mi funcion(); " pero no consigo que quede.... al estar dentro de form

agregue esta linea <form action method="POST" name="formulario" id="formulario" onsubmit="tipo(); ">

Código HTML:
<script type="text/javascript">
function init() {
    document.getElementById("select1").disabled = true;
}
function tipo(radio){
    document.getElementById("select1").disabled=(radio.value == 2)?true: false;
}
</script> 
</head>
<body onload="init()">

<table>
<tr>
<th>Tipo</th>
<td>
<input type="radio" name="tipo" value="1" onclick="tipo(this)" />Uno
<input type="radio" name="tipo" value="2" checked onclick="tipo(this)" />Ninguno
</td>
</tr>
<tr>
<th>Nombre</th>
<td>
<select name="select1" id="select1">
<option value="1">ABC</option>
<option value="2">DFG</option>
</select>
</td>
</tr>
</table>