PDA

View Full Version : Multiple onlick events for a single radio button?



nhoppe
08-12-2008, 05:17 PM
Hello,

This is a newbie question but I am trying to create a page for an application of mine where users have the ability to create alerts that are generated by the application for specific events. Much like the alerts generated by outlook for upcoming meetings in the calendar. The trouble I'm encountering is in the recurring options for these alerts.

User has two options for alert creation:

-1 time
-recurring

I have an onlick event for on the "recurring" radio button to "showArea" which contains the "recurring" options of:

-daily
-weekly
-monthly
-annually

My problem arises when attempting to use the same "showArea" logic for these radio buttons as used for the previous options.

-When the "daily" button is clicked, "daily options" appear
-When the weekly button is clicked, all other options should be hidden and "weekly options" should appear.
-When monthly button is clicked, all other options should be hidden and "monthly options" should appear

etc....

Is there a way to make a radio button show a hidden area when clicked and simultaneously hide others?

Bob90
08-12-2008, 05:29 PM
try


sectionsToHide = ["section1","section2","section3"]

function hideAll(){
var x;
for(x=0;x<sectionsToHide.length;x++){
document.getElementById(sectionsToHide[x]).style.display = "none";
}
}

then just add it at the beggining of your radio button onclick value.



<input type="radio" onclick="hideAll(),showSection()">


To summarise; you can add more than one function by using a comma ',' like an array.