Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Arrays/Functions

  • 19-03-2004 06:28PM
    #1
    Closed Accounts Posts: 3


    OK ive been trying this all day and cant get it right can anybody help?
    I have a button. When this button is pressed two functions are called. The first works fine but for the second to work i need to access a value in an array and use the answer from the first function to do some calculations.

    Ill explain what im doing to make it a little easier to understand

    The first function calculates speed per metre. I want the second function to use the athletes speed per metre to calculate their % of the world record for that particular distance. The world records for each distance are held in an array.

    I have tried all day to do this myself but i cant get my head around it. Here is some of my code if it will help:

    <!--function to calculate speed per metre-->
    <script>
    function doit()
    {
    var res=document.rpc
    var speed=res.speed.value
    res.speed.value=(res.distance.value/((res.hours.value*3600)+(res.minutes.value*60)+(res.seconds.value*1)));
    return speed;
    }
    </script>

    <!--function to calculate the distance-->
    <script>
    function distance()
    {
    var distance=document.rpc.distance.value
    if(document.rpc.distance.value="100")
    {
    document.rpc.wrspeed.value=(recordm[0]/document.rpc.speed.value);
    }
    }
    </script>

    <!--array-->

    <script type = "text/javascript">
    var recordm = new Array(10)
    recordm[0] =("9.79");
    .......

    Am i right in using an if satement?
    If anybody can give me feedback it would really help me thanks.


Advertisement