Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Click a checkbox to copy content from one form field to another

New Here ,
Oct 15, 2021 Oct 15, 2021

I am working on a form that will have 3 different sections — all with identical fields (“Attn”, “Company”, “ Address”, “City”, “State”, “Zip”, “Phone”, “Email”, etc). Each section may end up with different content, but may occasionally need to be the same. In this case, I would like the user to click a checkbox and have sections 2 & 3 auto-populate using the content from the fields in section 1. I am not versed in javascript, but I am hoping someone can give me a nudge in the right direction. Thanks in advance!

TOPICS
How to , JavaScript , PDF forms
774
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 15, 2021 Oct 15, 2021

Try this:

if(event.target.value != "Off"){
this.getField("Attn_2").value = this.getField("Attn").value;
this.getField("Attn_3").value = this.getField("Attn").value;
this.getField("Company_2").value = this.getField("Company").value;
this.getField("Company_3").value = this.getField("Company").value;
this.getField("Delivery Address_2").value = this.getField("Delivery Address").value;
this.getField("Delivery Address_3").value = this.getField("Delivery Address").value;}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2021 Oct 15, 2021

Lets say you have fields "Email1","Phone1" and "Email2","Phone2", as Mouse UP event of checkbox you can use script like this:

if(event.target.value != "Off"){
this.getField("Email2").value = this.getField("Email1").value;
this.getField("Phone2").value = this.getField("Phone1").value;}

Adapt code to your needs.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 15, 2021 Oct 15, 2021

Thank you for your reply. I added the script to the checkbox actions and get an illegal character error in the JavaScript Editor (see highlighted line in screenshot). Pardon my ignorance on this.

 

Screen Shot 2021-10-15 at 2.50.27 PM.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2021 Oct 15, 2021

Try this:

if(event.target.value != "Off"){
this.getField("Attn_2").value = this.getField("Attn").value;
this.getField("Attn_3").value = this.getField("Attn").value;
this.getField("Company_2").value = this.getField("Company").value;
this.getField("Company_3").value = this.getField("Company").value;
this.getField("Delivery Address_2").value = this.getField("Delivery Address").value;
this.getField("Delivery Address_3").value = this.getField("Delivery Address").value;}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 15, 2021 Oct 15, 2021
LATEST

Thank you so much for your help on this! This works exactly as I had hoped. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines