• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript for radio button

 
Mark Butcher
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Am working on javascript and struts 1.3.
Want to uncheck a radio button using javascript.
Have tried that and its not working for me.
Here is the jsp code :

and the javascript :

Thanks.
Mark
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The struts markup doesn't help us to know if your selector is correct. What's relveant is the actual HTML that is generated and sent to the browser.

But even if the selector is correct, why are you setting the value to false? The value has nothing at all to do with whether the radio element is checked or not. What you want to do is to set the checked attribute on the radio button.

Using jQuery (recommended) that'd be:
where whatever is the selector for the element.

In raw JavaScript, you use: document.getElementById('whatever').checked = true;

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I see that you want to uncheck. Same deal, just false.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic