Results 1 to 3 of 3

Thread: newbie, call function from anchor onClick?

  1. #1
    Join Date
    Jul 2010
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default newbie, call function from anchor onClick?

    Hi Guys

    Just want a bit of quick advice. So far in my adventures with Javascript I've used form inputs to pass parameters to my javascript functions, using the input's VALUE field.

    I'm wondering if it's possible to do the same with an anchor tag ? I'm guessing as there's no VALUE field, I can pass the paramter in the function call itself eg.

    Eg. to pass the parameter value 22 to myFunction....

    <a href="#" onClick="myFunction(22)">TEST</a>

    Is this OK ?

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <a href="#" onClick="myFunction(22);return false'
    ;">TEST</a>
    you will need the return false; to prevent the page reloading
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Jul 2010
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by vwphillips View Post
    Code:
    <a href="#" onClick="myFunction(22);return false'
    ;">TEST</a>
    you will need the return false; to prevent the page reloading
    thanks mate - that'll explain why my tests so far haven't been working, d'oh!

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
  •