Results 1 to 2 of 2

Thread: Multiple onlick events for a single radio button?

  1. #1
    Join Date
    Aug 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Multiple onlick events for a single radio button?

    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?

  2. #2
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default

    try

    Code:
    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.

    Code:
    <input type="radio" onclick="hideAll(),showSection()">
    To summarise; you can add more than one function by using a comma ',' like an array.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •