2012-11-19
 
Kategorie
 

A link in a form to a file from the layout

 

A link in the layout

Sometimes you need to link a document, e.g. a PDF file with Terms and Conditions. It’s easy when you want to insert the link in the layout. Just add the file in the file tree in the Design tab, as shown below:

Add the following code to the HTML file:

<a href="$misc/regulations.pdf$" target="_blank">Link</a>

A link in the form

It’s no longer that easy when you want to insert the link not in the layout but in the form, for example in the “Confirmation checkbox” or “HTML area” field. Calling “$misc/” will not work in such a situation. Here’s how you can bypass the problem.

Add the following code in the relevant field:

<a href="" target="blank" id="link_id">Link</a>

and the following code at the bottom of the Body section in the HTML layout file:

<script language="JavaScript">
if (getPageNumber() == 1) {
  document.getElementById("link_id").href="$misc/regulations.pdf$";
}
</script>

and now you can enjoy your link in the form. For more about inserting JavaScript in layouts, see here.

 
 
recent posts
3rd Apr 2014
Faster than ever!
5th Dec 2013
Live validation!
2nd Dec 2013
Features distilled
12th Mar 2012
Flicking Channels
26th Jan 2012
Your Own Error Page
9th May 2011
Box Properties
15th Apr 2011
Grouping Fields
13th Apr 2011
Form Versioning
24th Feb 2011
Form Access Modes
22nd Feb 2011
Required Fields
4th Feb 2011
Stats!