Hyperlink syntax error

I can’t figure this problem out with a HTML hyperlink:
This is the code to set the hyperlink:

'<td><a href="javascript:globals.myMethod("'+ myvar + '")"><font color="394d66">' + myvar + '</font></a></td>' +

The URL seems to look good in the HTML:

<td><a href="javascript:globals.myMethod("active")"><font color="394d66">active</font></a></td>

But when I click on the hyperlink I get an error message saying that it can’t evaluate the string: ‘globals.myMethod(’.

Even when I use:

'<td><a href="javascript:globals.MyMethod(' + myvar + ')"><font color="#394d66">' + myvar + '</font></a></td>\n' +

I recieve a similair error message, but then it contains also the variable and the details returns that “active” is not defined.
:?

Hi Karel, you need to use single quotes and escape them properly like this if you are passing a string as a parameter to the method:

javascript:globals.myMethod(\''+ myvar + '\')

If you are passing a number non need for quotes.

As already reported here: http://forum.servoy.com/viewtopic.php?t=4253
the parameter must be enclosed in single quotes:

for dropping a single quote in a string you can use the more confortable and readeable ' instead of … + “'” + …

so you can try with:

<font…’

hope this helps

ciao

Thank you so much, Nicola! That did it!