# javascript:mymethod(value) usage in HTML

**URL:** https://forum.servoy.com/t/javascript-mymethod-value-usage-in-html/1924
**Category:** Classic Servoy
**Created:** [May 22, 2004, 2:36pm UTC](https://forum.servoy.com/t/javascript-mymethod-value-usage-in-html/1924 "2004-05-22T14:36:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)
#### Post date: [May 22, 2004, 2:36pm UTC](https://forum.servoy.com/t/javascript-mymethod-value-usage-in-html/1924/1 "2004-05-22T14:36:27Z")

</div>

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:

```auto
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!

---

<div class="post-metadata">

### Author: ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)
#### Post date: [May 22, 2004, 2:55pm UTC](https://forum.servoy.com/t/javascript-mymethod-value-usage-in-html/1924/2 "2004-05-22T14:55:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)
#### Post date: [May 22, 2004, 4:18pm UTC](https://forum.servoy.com/t/javascript-mymethod-value-usage-in-html/1924/3 "2004-05-22T16:18:35Z")

</div>

Hi Paul,

The string looks like this

```auto
<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.

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

```

---

<div class="post-metadata">

### Author: ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)
#### Post date: [May 22, 2004, 4:41pm UTC](https://forum.servoy.com/t/javascript-mymethod-value-usage-in-html/1924/4 "2004-05-22T16:41:12Z")

</div>

What the…

It works now! ![:D]( "Very Happy")  
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:]( "Shocked")

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 ![:)]( "Smile")  
Thanks for thinking with me!

---

<div class="post-metadata">

### Author: ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)
#### Post date: [May 22, 2004, 8:08pm UTC](https://forum.servoy.com/t/javascript-mymethod-value-usage-in-html/1924/5 "2004-05-22T20:08:34Z")

</div>

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]( "Very Happy")
