SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to call a Js function with array parameter direct from HTML?

    Hi,

    Title should be partly self-explanatory.

    I have a situation where I need to make a function call direction from HTML (i.e. using something like onClick="myFunction(myParam1, myParam2);") but the problem is that I'd like, ideally, to pass a javascript array as a parameter instead of values, for example:

    HTML Code:
    <script>
    myArray[0] = myParam1;
    myArray[1] = myParam2;
    </script>
    onClick="myFunction(myArray);"
    Which, if enacted as written, I would assume is going to do something like attempt to call myFunction with a string parameter of "myArray" and fail horribly.

    I can't see any straightforward way of doing this. Is there one?

    Cheers,
    Matt

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Scratch this - I can do what I need by referencing function.arguments.

    Cheers,
    Matt


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •