Skip to main content
Participating Frequently
October 2, 2017
Answered

Auto-populate form fields when a check box is ticked

  • October 2, 2017
  • 3 replies
  • 11312 views

Hi,

I am creating a form to collect new account information.  I have some fields that will be mandatory including 'contact name' and 'owner name'.  What I want is for the text field of 'contact name' to auto-populate with the text from 'owner name' if the customer ticks a check box that says 'tick if same as above'.

I have done some digging online and the best script I found so far was;

if (getField("Check Box 21").value!="On")

this.getField(“Contact Name”).value = this.getField(“Owner Name“).value;

But I am getting this error;

SyntaxError: missing ) after argument list 2: at line 3

Any advice on how to fix this would be great.

Thanks!

This topic has been closed for replies.
Correct answer try67

Again, thank you so much for your time and help with this.

the dropbox link is

Dropbox - 5. Drafts


Use this code:

if (event.target.value!="Off")

    this.getField("CONTACT NAME").value=this.getField("OWNER NAME").value;

3 replies

Participating Frequently
April 28, 2020

Can I please get help with a code for when a box is tick a form field populates a number. For example when a check box is tick a form field will have the number 3 on it. 

Participant
March 5, 2020

When unselecting the check mark it leaves the filled content. If I unselect the check mark I want it to go back to being blank. Is there code for that? 

Thank you 

try67
Community Expert
Community Expert
October 2, 2017

You need to use a plain-text editor to write the code and make sure you're only using "straight" double-quotes, not "fancy" ones like those used in Word.

Also, is the export value of your check-box really "On"? By default it's "Yes". The value when the field is not ticked is always "Off", so it's better to use that.

Participating Frequently
October 3, 2017

Thanks for your help.

I'm still have a problem.  I have used this script;

if (getField("Check Box 21").value!="Yes")

this.getField("OWNER NAME").value = this.getField("CONTACT NAME");

But it isn't working. I type in the 'Owner Name' field and then when I tick the check box nothing appears in the 'Contact Name' and the text in the 'Owner Name' changes to [object Field].

Do you know why this is happening?

Thank you!

try67
Community Expert
Community Expert
October 3, 2017

You have it the wrong way around, and there's a mistake in your code. It should be:

if (getField("Check Box 21").value!="Yes")

    this.getField("CONTACT NAME").value = this.getField("OWNER NAME").value;