> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.metalocator.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Data driven links

Each location in the results is rendered with a series of Field Templates. Each Field Template has access to the entire result object, search for states and URL parameters. See the [Field Templates](https://support.metalocator.com/en/articles/3817982-field-templates) documentation for details and reference.

Sometimes, our customers need to pass specific variables to a javascript function or create links dynamically based on data in the result. A simple example would be to create a link with the result name added as a URL parameter:

```
https://example.com?locationName=Mike's Example
```

## Dynamic Links

Links of this type can be added directly to the MetaLocator result card. The simplest way is to add a **Text** or **Button** field to the results card as shown below:

[![](https://storage.crisp.chat/users/helpdesk/website/-/9/d/1/1/9d11982116159000/fd52bf5c-eadb-4ccd-b7c8-ce7a1e_1uk9a4v.png)](https://downloads.intercomcdn.com/i/o/1078848822/c918a687b980ba03ac3ae559/image.png?expires=1794513600&signature=0fced7c4c9952e21ac0fbbeac527704f3a83c2eb190f29cd1cad556fcaeb37b4&req=dSAgHsF6lYldW%2FMW1HO4zfuUEHvmvmHtTuFP1O7tAkM99ZdjGEPK3rGuP9DI%0ATz8xfGPZb%2FF1mh1XR6I%3D%0A)

You can also modify an existing field, such as the system **Link** field. This approach is better if the link itself is coming from the data.

Regardless of the field you start with, the HTML markup for a dynamic link will be materially the same:

```
<a href="https://example.com?locationName={{name}}"  target="_blank"  data-toggle="tooltip" data-placement="top" title="" class="ml_label ml_button ml_button  ">{{name}}</a>
```

The code above can be inserted into the **Field Template** of any field. Below, we've inserted that into a **Button** field added to the results card.

[![](https://storage.crisp.chat/users/helpdesk/website/-/6/9/8/f/698fd801c1df9c00/56bc622a-4f0e-4550-b26f-0e53ce_p0n25w.png)](https://downloads.intercomcdn.com/i/o/1078860906/f968982306c5f0d2eac7f4f2/image.png?expires=1794513600&signature=c7e5384b2f0e62d3b36d2369813701e71ff25e9e5403d3d65c01337aa1fa2c87&req=dSAgHsF4nYhfX%2FMW1HO4zbocvRxiIs2q6QRfn8hcNmBGmwcOLczIwsZOqXws%0AQh9VXfuuWsXy02LHCCk%3D%0A)

The variable {{name}} will be replaced dynamically with the name of the location in the URL Parameter (shown below in the lower left) and the displayed name of the button.

[![](https://storage.crisp.chat/users/helpdesk/website/-/2/b/0/c/2b0c7fea8ce26000/2526bb5a-5994-4ba6-97d0-28591a_1mhadfl.png)](https://downloads.intercomcdn.com/i/o/1078869659/ac1daa937f54f7fc175a7f4c/image.png?expires=1794513600&signature=0e56b8efe7df716c52860387403919a3444ceccf574f564bd33ccadbf3aff269&req=dSAgHsF4lIdaUPMW1HO4zcVxpCf6gJQvkhZmHv0xagT7onJ3Gg%2Fik1KfjNRF%0AgzUkYagSjS9To6SlgUw%3D%0A)

## Dynamic Javascript

Calls to javascript functions can be authored in a similar way as described above. In the below example, the javascript function receives parameter values defined by data in MetaLocator:

```
<a href="#" onclick="javascript:doSomething({{id}},'{{esc name}}','{{customfieldvalue}}');" target="_blank"  data-toggle="tooltip" data-placement="top" title="" class="ml_label ml_button ml_button  ">{{name}}</a>
```

The **esc** function in the _name_ reference above replaces single & double quotes to avoid quotes within the data breaking the format of the javascript function call.