arrays and functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • john

    arrays and functions

    looking for a way to pass an array to a function.
    =============== =============== ======
    <script>
    function myfunction(arra yname)
    {
    document.write( "blablabla" + arrayname[1] +"blablabla" );
    }
    </script>

    <html stuff>

    <script>
    arrayname = new Array("what", "is", "wrong");
    myfunction(arra yname);
    </script>
    =============== =============== ======


    why wont this work

    john
  • Lee

    #2
    Re: arrays and functions

    john said:[color=blue]
    >
    >looking for a way to pass an array to a function.
    >============== =============== =======
    ><script>
    > function myfunction(arra yname)
    > {
    > document.write( "blablabla" + arrayname[1] +"blablabla" );
    > }
    ></script>
    >
    ><html stuff>
    >
    ><script>
    > arrayname = new Array("what", "is", "wrong");
    > myfunction(arra yname);
    ></script>
    >============== =============== =======
    >
    >
    >why wont this work[/color]

    The code you posted works just fine.
    Why not try posting the actual code that fails?


    <html>
    <body>
    <script>
    function myfunction(arra yname)
    {
    document.write( "blablabla" + arrayname[1] +"blablabla" );
    }
    </script>

    <p>HTML Stuff</p>

    <script>
    arrayname = new Array("what", "is", "wrong");
    myfunction(arra yname);
    </script>
    </body>
    </html>

    Comment

    Working...