more than one function attached to a button

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

  1. #1
    im trying to make a button click do 5 different functions at once, each with a separate output that will have differing values, how do i make this work? this is the code thus far....

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

    <script language='Javascript'>

    var zoneList;
    var hoursBox;
    var centralTimeBox;
    var mountainTimeBox;
    var pacificTimeBox;
    var alaskaTimeBox;
    var hawaiiTimeBox;
    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>

    o'clock

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


    <p><input type=text name=centralTimeBox size=8> In the Central time zone
    </p>
    <p><input type=text name=mountainTimeBox size=8> In the Mountain time zone
    </p>
    <p><input type=text name=pacificTimeBox size=8> In the Pacific time zone
    </p>

    <p><input type=text name=alaskaTimeBox size=8> In the Alaskan time zone
    </p>
    <p><input type=text name=hawaiiTimeBox size=8> In the Hawaiian time zone
    </p>

    <p> </p>

    <input type=button value="Update"
    onclick="document.timezones.centralTimeBox.value=east2cent(document.timezones.hoursBox.value)";
    &&document.timezones.mountainTimeBox.value=east2mount(document.timezones.hoursBox.value)";
    &&document.timezones.pacificTimeBox.value=east2pac(document.timezones.hoursBox.value)";
    &&document.timezones.alaskaTimeBox.value=east2alaska(document.timezones.hoursBox.value)";
    &&document.timezones.hawaiiTimeBox.value=east2hawaii(document.timezones.hoursBox.value)";>

    </form>
    </body>

    </html>

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

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #2
    you can try :

    onclick="buttoncl()"

    function buttoncl() {
    document.timezones.centralTimeBox.value=east2cent(document.timezones.hoursBox.value)
    document.timezones.mountainTimeBox.value=east2mount(document.timezones.hoursBox.value)
    document.timezones.pacificTimeBox.value=east2pac(document.timezones.hoursBox.value)
    document.timezones.alaskaTimeBox.value=east2alaska(document.timezones.hoursBox.value)
    document.timezones.hawaiiTimeBox.value=east2hawaii(document.timezones.hoursBox.value)

    }
     
    gibex, May 12, 2007 IP