Resources/Get more here/Forms & Form Data

Add third-party javascript to your form(s)

Jessica Collier
posted this on Jan 23 11:51

A number of marketing software packages provide javascript that customers can plug into HTML form pages to seamlessly route form data to another system, perform client-side validation, analyze partial form completion, etc. To better integrate with these services, every form in LiveBall is identified with "name" and "id" attributes of "liveballform".

For example:

<form name="liveballform" method="post" id="liveballform">

This makes it easy for Javascript to quickly reference the form. In addition, all of the fields in LiveBall forms have the name and id of their underlying data collection data name.

For example:

<input type="text" name="firstname" id="firstname" value="" size="40" maxlength="40" />
<input type="text" name="lastname" id="lastname" value="" size="40" maxlength="40" />
<input type="text" name="email" id="email" value="" size="80" maxlength="80" />

This makes it easy for Javascript to look at the specific values of fields (and, at their option dynamically tweak them) in a consistent and predictable manner. To further leverage this capability, there are two additional features in the "page script" editor:

  1. A hook for a form's onsubmit Javascript event, for instance to plug in a "myvalidation();" in the form tag, like this: <form name="liveballform" onsubmit="myvalidation();" ...>.
  2. A hook to insert additional HTML or Javascript ("Form script") in between the <form></form> tags. This is primarily intended to enable "hidden" form fields to be added to a form, as a way of passing extra info to a 3rd-party system during an "onsubmit" event. For instance, to dynamically add a hidden form field that includes an assigned CampaignCode, you would add the following form script:

 <input type="hidden" name="campaigncode" value="@@campaigncode" />

Notice the ability to use @@ variables to substitute any data that you've already collected or assigned to the respondent at the time which the form is rendered.