Results 1 to 3 of 3

Thread: JavaScript - Including java script in hyperlink?

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

    Default JavaScript - Including java script in hyperlink?

    Hello, I've tried this syntax which is supposed to allow a script
    to be included inside a hyperlink, to be run onClick.

    Code:

    Code:
    <a href="23" onClick="<script language = 'javascript'> sessvars.whichpage=3; </script>" <img>  </img> </a>


    The script simply will not run-- it is supposed to assign a value
    to variable sessvars.whichpage, but when I get to my destination (node 23) its value shows as undefined.

    Is there something wrong with my syntax?

    Many thanks,

    lmalinofsky

  2. #2
    Join Date
    Jul 2008
    Posts
    128
    Thanks
    0
    Thanked 17 Times in 16 Posts

    Default

    Code:
    <a href="23" onClick="sessvars.whichpage=3;"><img>  </img> </a>

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    clueful's response is correct for javascript. However, it looks as though you may be trying to assign a value to a server side variable. This can be done, but it's a little more complicated.

    Is this what you are trying to do? If so, what server side language are you using?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •