Forum Moderators: open

Message Too Old, No Replies

Event handler (Onclick) question regarding <A> object

Onclick is supposed to be an event for the <A> hypertext method

         

RooDood

9:14 pm on Dec 2, 2007 (gmt 0)

10+ Year Member



I am just trying to change a variable value if the event handler is used (clicked on). Can anyone answer my questions below.

I have displayed the value of "p", which shows the initial assigned value "-1" being assigned correctly but I have tried all kinds of ways to write the function but unable to get the value to change. It would be helpful if there was a way to display from the HEAD tag.

1) Is there a way to display fields in the HEAD tag area? I would like to display what happens there.
2) The script code (simplest version) I have is below, it is my understanding that the <A> (hypertext) event handler includes "onclick". It is difficult to know whether code is being processed and if not if it is due to syntax or that the event is not handled by the method without a way to display variable values within the function.

What I have in the Head tag:
<SCRIPT language="JavaScript">
var p = -1;
var n = -1;
function clicklink ( n )
{
p = n;
}
</script>

In the body tag:
<a href="#Top" onclick="clicklink( -2 );return true">
<span style="text-decoration: none">Return to top</span></a>

rocknbil

11:21 pm on Dec 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard RoodDude, doesn't alert() tell you what you need to know?

function clicklink ( n )
{
p = n;
alert('value is now '+p);
}