Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mootools set radio button checked

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 it is not working at all.

Any help will be appreciated... and any other short solution without the if-condition.

like image 211
Gobi Avatar asked Apr 06 '10 07:04

Gobi


2 Answers

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

like image 104
Oskar Krawczyk Avatar answered Nov 05 '22 17:11

Oskar Krawczyk


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.

like image 37
nekman Avatar answered Nov 05 '22 17:11

nekman