File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes javascript for radio button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript for radio button" Watch "javascript for radio button" New topic

javascript for radio button

Mark Butcher
Ranch Hand

Joined: Jun 28, 2012
Posts: 46
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 :

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

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;

[Asking smart questions] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

Oh, I see that you want to uncheck. Same deal, just false.
I agree. Here's the link:
subject: javascript for radio button
It's not a secret anymore!