trying to link more than one function to a button

Discussion in 'JavaScript' started by Kankles137, May 11, 2007.

  1. #1
    alrite, i got thos far, i need to link 5 different functions to one button, so wen the button is clicked, depending on wat value is in a pulldowntab, one of the 5 functions will run. this is it so far....

    <html>
    <title> Time Zones </title>
    <head> <h2> U.S. Time Zones </h2> </head>
    <body>

    <script language='Javascript'>

    var zoneList;
    var hoursBox;
    var shiftedTimeBox;

    var ampm;

    function east2cent (hoursBox)
    {return hoursBox - 1;
    }
    function east2mount (hoursBox)
    {return hoursBox - 2;
    }
    function east2pac (hoursBox)
    {return hoursBox - 3;
    }
    function east2alaska (hoursBox)
    {return hoursBox - 4;
    }
    function east2hawaii (hoursbox)
    {return hoursBox - 5;
    }

    </script>

    <form name=timezones>
    When it is
    <input type=text name=hoursBox size=6
    onChange="document.timezones.shiftedTimeBox.value=east2cent(document.timezones.hoursBox.value)">

    o'clock

    <select name=ampmList>
    <option value="am">am
    <option value="pm">pm
    </select>
    In the Eastern time zone
    <p>It is

    <input type=text name=shiftedTimeBox size=8>
    In the
    <select name=zoneList>
    <option value="Hawaii">Hawaii
    <option value="Alaska">Alaska
    <option value="Pacific">Pacific
    <option value="Mountain">Mountain
    <option value="Central">Central
    </select>
    Time zone
    <p> </p>

    <input type=button value="Update"
    if (zoneList == Central)
    onclick="document.timezones.shiftedTimeBox.value=east2cent(document.timezones.hoursBox.value)";
    ||
    if (zoneList == Mountain)
    onclick="document.timezones.shiftedTimeBox.value=east2mount(document.timezones.hoursBox.value)";
    ||
    if (zoneList == Pacific)
    onclick="document.timezones.shiftedTimeBox.value=east2pac(document.timezones.hoursBox.value)";
    ||
    if (zoneList == Alaska)
    onclick="document.timezones.shiftedTimeBox.value=east2alaska(document.timezones.hoursBox.value)";
    ||
    if (zoneList == Hawaii)
    onclick="document.timezones.shiftedTimeBox.value=east2hawaii(document.timezones.hoursBox.value)";>

    </form>
    </body>

    </html>

    any help would be greatly appreciated, thx alot
     
    Kankles137, May 11, 2007 IP