Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/05/2011, 21:20
everitosan
 
Fecha de Ingreso: mayo-2011
Mensajes: 2
Antigüedad: 13 años
Puntos: 0
Pregunta Seleccionar y de-seleccionar radio botones

Sucede que soy novato en javascript, y he intentado hacer una función que al dar click en un radio botón, se de-seleccionen automáticamente los demás.

estos son los botones:


<form name="agregar">
<input type="radio" value="Fiesta" name="r1 "id="F" onclick="deshabilitar(1)"/>Fiesta
<input type="radio" value="Concierto" name="r2" id="C" onclick="deshabilitar(2)"/> Concierto
<input type="radio" value="Escuela" name="r3" id="C" onclick="deshabilitar(3)"/> Escuela
<input type="radio" value="Antro & Bar" name="r4" id="C" onclick="deshabilitar(4)"/> Antro & Bar
<input type="radio" value="Marcha" name="r5" id="C" onclick="deshabilitar(5)"/> Marcha
<input type="radio" value="Evento" name="r6" id="C" onclick="deshabilitar(6)"/>Evento
</form>

y esta es la función:

<script>

function deshabilitar(n){

for(a=n+1;a<7;a++){ eval("document.agregar.r"+a+".checked= false"); }



b=n-1;
while(b>0)
{eval("document.agregar.r"+b+".checked= false");
b=b-1;
}

}


</script>


todo funciona bien excepto con el primero, ya que al seleccionarlo una vez, no se de-selecciona cuando selecciono algún otro. Espero me pueda ayudar.