Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Arrays/Functions

  • 19-03-2004 5: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