This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript for radio button

 
Mark Butcher
Ranch Hand
Posts: 46
  • 0
  • 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: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I see that you want to uncheck. Same deal, just false.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic