View Full Version : JavaScript - Including java script in hyperlink?

06-30-2010, 05:58 PM
Hello, I've tried this syntax which is supposed to allow a script
to be included inside a hyperlink, to be run onClick.


<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,


06-30-2010, 09:06 PM
<a href="23" onClick="sessvars.whichpage=3;"><img> </img> </a>

07-01-2010, 12:43 AM
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?