Using Javascript to change form content or behavior

Posted by

Let’s assume you have a form. You customized it how you wanted. And now, you want to dynamically change field values, or maybe to programmatically trigger some events (clicking the Submit button, the Next Page button etc.).

To achieve this, you can add a custom JS script to your form. Now you need to add the actual code to the script. Each field on the form has a unique ID, which you can easily locate using the Inspector / Firebug feature of your browser.

Using the field IDs that you identify, you can configure your form to do various things. For example, once the form is loaded, you can prefill the fields with any values you wish.

This is a demo form that prefills various types of fields. And this is the JS code that triggered this behaviour.

Let us know if you have any questions.

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *