Mootools radio control switch installed

I have 2 switches

and I used mootool when 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 it does not work at all.

Any help would be appreciated ... and any other short solution without an if-condition.

+5
source share
2 answers

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

+5
source
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);
});

do not forget to add}); at the end of the addEvent function.

+2
source

All Articles