javascript function question

Associate
Joined
8 Mar 2007
Posts
2,176
Location
between here and there
hey guys,

I have a function that does some stuff and is fired on a onclick event.

There are 38 of these onclick events and I need to pass the name of one of 38 gobal varaibles to the function to be used there.

If i do...

var1 = "test"

onclick="functionname(var1)"

to call the function and in the function...

function functionname(q)
alert(q)

it displays "var1" not "test"


Anyone got any ideas how to pass this varaible name to the function and not as a string??

Cheers in advance guys :)
 
Code:
var myVar = "ocuk";
alert('The value of myVar is: ' + myVar);

You declared you variable slightly wrong :)
 
sorry that was just an example...

I'm trying to pass a varaible NAME to a function not a string.

is there anyway??
 
Back
Top Bottom