javascript:mymethod(value) usage in HTML

I am psyched about the usage of HTML inside of Servoy. So many wonderful things are possible with it but it seems that calling a method from HTML inside a global field is an issue.

I fill the field by using a method and the href part looks like this:

HTML += '<a href=\"javascript:showdate(' + startDate.getDate() + ');\">' + startDate.getDate() + '</a>';

Now when I click the URL the script seems to hang. The debugger pause and stop buttons are active.
Even when I comment everything out in the method I am calling this happends.
Also adding return true or false has the same result.

What am I missing here.

Servoy 2.0.2-build 275
Java version 1.4.2-34 (Mac OS X 10.3.3)

Thanks in advance!

How does the string of HTML that you create with the bit of code you provided? Seeing that will make it easier to look what’s going on…

Couple of things I see right away: <a href=.…: why the "" in there?

Also, in the actual HTML there have to be single quotes aroung the param values that you pass to the method. Example:

(’ + startDate.getDate() + ');

should be:

(’ + “'”+startDate.getDate()+“'” + ');

Hope this will get you going… If not, pleas epost the bit of actual HTML that is not working as well.

Paul

Hi Paul,

The string looks like this

<a href="javascript:showdate(5)">5</a>

Since I am using a string in javascript I have to escape the double quotes in the method. So therefore the " in de code.
Also using single quotes around the value like in the following code doesn’t do the trick.

<a href="javascript:showdate('5')">5</a>

What the…

It works now! :D
I filled a wrong global variable with some value so I fixed that. But still it didn’t work. Now after more testing with different parameters it started working. :shock:

I wonder if Servoy keep things in memory and don’t purge them until overwritten or something.

Odd.

Anyway, I am happy it works as advertised now :)
Thanks for thinking with me!

No problem… these funny things happen to me as well

I have a strange situation, where a specific effect of a stylesheet doesn’t appear, untill I load another piece of HTML into my global first and after that relaod the piece of HTML I actually want in there…

So, it seems Servoy somehow does keep some stuff in memory

Paul

BTW: that " makes the strings more readable, I’ll have to start using it :D