views:

648

answers:

3

Hi

i have 2 radio buttons

and i used mootool while loading as

 window.addEvent('domready', function() {
   var chk="1";
 if(chk==1){

$('edit-gender-0').set('checked',true);
 }

else if(chk==2){
 $('edit-gender-1').set('checked',true);

  }

but its not working at all.

any one help me will be more appreciated... and anyother short way without if condition

+2  A: 

The code you've provided works just fine - here's a test-case: http://jsfiddle.net/oskar/tM29a/

Oskar Krawczyk
+1  A: 
window.addEvent('domready', function() {
   var chk="1";
   if(chk==1){
      $('edit-gender-0').set('checked',true);
   } else if(chk==2){
      $('edit-gender-1').set('checked',true);
});

don't forget to add }); at the end of the addEvent function.

Nisse
A: 

set('checked',true) does not work in mootools 1.1. A problem Im having with radios.

Andy