aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Enable-Diable Radio Buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Enable-Diable Radio Buttons" Watch "Enable-Diable Radio Buttons" New topic
Author

Enable-Diable Radio Buttons

Anand Jayaraman
Ranch Hand

Joined: Jan 28, 2004
Posts: 104
Hi...


I have been having this problem for a while. I have two radio buttons and when the user clicks on the first one, two new radio buttons must be enabled for the user to use (by default, the last set of radio buttons are diabled).

For example:



In the above code, A11 and A22 are disabled by default. When the user selects the first radio button, i.e, A, I want to enable radio buttons, A11 and A22.

I wanted dynamic radio buttons, but have now settled for this. Can someone help me with this???



Cheers
Anand Jayaraman
Ranch Hand

Joined: Jan 28, 2004
Posts: 104
Hello!

I tried something like this, but there is a problem with this.



However, what this does is, it enables the first radio button (i.e A11) and DOES NOT ENABLE THE OTHER ONE...


Any fix???
Pedro Penna
Ranch Hand

Joined: Jun 05, 2004
Posts: 46
Try this:

<script>
function toggle(bool) {
document.getElementById("targetRadio1").disabled = bool;
document.getElementById("targetRadio2").disabled = bool;
}
</script>

<input type="radio" name="r1" on click="toggle(true)" value="1" />
<input type="radio" name="r1" on click="toggle(false)" value="2" />
<br />
<input type="radio" name="r2" value="3" id="targetRadio1" disabled />
<input type="radio" name="r2" value="4" id="targetRadio2" disabled />

All you have to do now is remove the internal space in the event handlers "on click". JavaRanch just won't let me include a post including this word... Aparently there's some evil conspiracy theory involving JavaScript or something like that...

If you want dinamically generated radio buttons, all you have to add is a loop statement to build the "id" attribute, like "targetRadio" + x
Anand Jayaraman
Ranch Hand

Joined: Jan 28, 2004
Posts: 104
Right On!

Thanks for that! People have always wondered why Aussies spell words differently. I'd attribute my spelling to Javaranch.. (If you noticed my onKlick in the code above)


Cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enable-Diable Radio Buttons