# use hyperlink to run method

**URL:** <https://forum.servoy.com/t/use-hyperlink-to-run-method/3989>\
**Category:** Classic Servoy\
**Created:** [April 5, 2005, 9:07pm UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989 "2005-04-05T21:07:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [April 5, 2005, 9:07pm UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/1 "2005-04-05T21:07:23Z")

</div>

Is it possible to run a method from a hyperlink in a label?

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [April 6, 2005, 6:21am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/2 "2005-04-06T06:21:15Z")

</div>

YEP! Starting in Servoy 2.0:

```auto
<a href="javascript:formMethod()">Click Here</a>

```

If you want to pass a parameter to the method:

```auto
<a href="javascript:formMethod('1')">Click Here</a>

```

**NOTE:** The parameter MUST be enclosed with single quotes!

If you want to call a global method and pass a parameter:

```auto
<a href="javascript:globals.method('1')">Click Here</a>

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [April 6, 2005, 7:45am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/3 "2005-04-06T07:45:28Z")

</div>

Allright! Is this functionality also included in the ‘Help’? That would be nice, too ![:wink:]( "Wink") !

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [April 6, 2005, 11:01am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/4 "2005-04-06T11:01:25Z")

</div>

> bcusick:  
> YEP! Starting in Servoy 2.0:
> 
> ```auto
> <a href="javascript:formMethod()">Click Here</a>
> 
> ```

Hmmm.. I do see the HTML correct in the label, but the method just doesn’t run… this is what I do:

```auto
<a href="javascript:SearchA()">A</a>

```

Any idea what’s missing here?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [April 6, 2005, 11:06am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/5 "2005-04-06T11:06:01Z")

</div>

Looks like you are creating a search by letters. I do the same, here is the code that works for me

```auto
var method = yourmethod
var letter = new Array('a', 'b', ...)

// I use this in a loop over my letter array
// this portion just takes care of creating the link!
html += '<td align="center"><a href="javascript:'
html += method + '(\''
html += letter[i]
html += '\')">'
html += letter[i]
html += '</a></td>'

```

Hope it helps.

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [April 6, 2005, 11:22am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/6 "2005-04-06T11:22:11Z")

</div>

> patrick:  
> Looks like you are creating a search by letters.

That’s right! I try to use a label with HTML code to activate the search method. The result appears in a tableview and not in HTML though… Thing is that the method just not activates from clicking on the hyperlink in the label…

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [April 6, 2005, 11:31am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/7 "2005-04-06T11:31:33Z")

</div>

Wouldn’t it be easier if you construct your search as

```auto
<a href="javascript:Search('A')">A</a>

```

and in that method Search you do a

```auto
var letter = arguments[0] // delivers A in the example above

```

That way you only need 1 search method and not one for every letter.

Your problem might be that the method SearchA is not in the same form as the html? Then it should be forms.your\_table\_view.searchA().

---

<div class="post-metadata">

**Author:** ![mnorman](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@mnorman](https://forum.servoy.com/u/mnorman)\
**Post date:** [April 6, 2005, 6:08pm UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/8 "2005-04-06T18:08:17Z")

</div>

> freecolours:  
> Allright! Is this functionality also included in the ‘Help’? That would be nice, too ![:wink:]( "Wink") !

Karl,

This functionality is included in the online Servoy Help  
Navigator as well as in the printed Servoy Developer Edition Volume 1:  
User’s Guide under the Fields section.

In the Servoy Help Navigator:

- Choose Help\>Help (F1).  
-Click once to select the Index tab.  
-Enter “method” in the search criteria box.  
-Double click on the sub-index entry “Calling a method from a field”.

This will open the Fields section.

-Choose Tools\>Find.  
-Enter “calling a method” in the “Find What” box.  
-Press the “Find Next” button to go directly to the information and  
example on “Calling a method directly from a field”.

In the printed Servoy Developer Edition Volume 1: User’s Guide:

See the Chapter 7 Forms; Section 7.9 Form elements;  
Subsection 7.9.3.2 Calling a method directly from a field; page 203.

* * *

Marc Norman  
Servoy

---

<div class="post-metadata">

**Author:** ![Jan\_Aleman](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jan\_Aleman](https://forum.servoy.com/u/Jan_Aleman)\
**Post date:** [April 6, 2005, 7:13pm UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/9 "2005-04-06T19:13:26Z")

</div>

> freecolours:  
> Allright! Is this functionality also included in the ‘Help’? That would be nice, too ![:wink:]( "Wink") !

If you would have actually read the help you would also know that you have to put the html in a global field instead of on a label.

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [April 7, 2005, 7:37am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/10 "2005-04-07T07:37:18Z")

</div>

> jaleman:  
> If you would have actually read the help you would also know that you have to put the html in a global field instead of on a label.

That’s what I wanted to hear! Hyperlinks don’t work in labels, but in globals! (HTML works fine in labels, though…)  
I wonder if the help really does say that you can’t use hyperlinks in labels… But thanks anyway, Jan!

---

<div class="post-metadata">

**Author:** ![Jan\_Aleman](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jan\_Aleman](https://forum.servoy.com/u/Jan_Aleman)\
**Post date:** [April 7, 2005, 7:40am UTC](https://forum.servoy.com/t/use-hyperlink-to-run-method/3989/11 "2005-04-07T07:40:58Z")

</div>

> freecolours:  
> I wonder if the help really does say that you can’t use hyperlinks in labels… But thanks anyway, Jan!

How about reading the help? Using hyperlinks is discussed in the fields chapter and not in the labels chapter, I wonder if that is coincidence.
