Expand my Community achievements bar.

SOLVED

Auto-populate based on check box

Avatar

Level 1

I am fairly new to the whole scripting idea in both Javascript and Formcalc for forms. I have created a form that needs some dear attention. What I am trying to do is autopopulate text fields based off the checkbox, if it's turned on or not.

Example:  Once the property information - property name, street address, city, state and zipcode (at the top of form) is filled in. If the check box is checked in the Payer information section (at the bottom) it will enter the information from the property information in the address fields below in the assigned text fields.

Here is my Javascript code (not complete):

FLContract.#subform[0].PayerName::calculate - (JavaScript, client)

var a =""

if (this.getField(CheckBoxPropertyInfo).value == 1)
{
a=PropName.value
}
event.value=a

Capture.PNG

1 Accepted Solution

Avatar

Correct answer by
Level 2

Enter this under the "Change" option of the script editor for the checkbox. just rename your fields appropriately. The second "If" will reset the fields if they accidently clicked it. Name[1] is the field you want the checkbox to fill. 'Name' is the original field.

if (this.rawValue == "1") {

  this.resolveNode("Name[1]").rawValue = this.resolveNode("Name").rawValue;

  this.resolveNode("Address[1]").rawValue = this.resolveNode("Address").rawValue;

  this.resolveNode("City[1]").rawValue = this.resolveNode("City").rawValue;

  this.resolveNode("State[1]").rawValue = this.resolveNode("State").rawValue;

  this.resolveNode("ZipCode[1]").rawValue = this.resolveNode("ZipCode").rawValue;

  this.resolveNode("Country[1]").rawValue = this.resolveNode("Country").rawValue;

}

if (this.rawValue == "0") {

  this.resolveNode("Name[1]").rawValue = "";

  this.resolveNode("Address[1]").rawValue = "";

  this.resolveNode("City[1]").rawValue = "";

  this.resolveNode("State[1]").rawValue = "";

  this.resolveNode("ZipCode[1]").rawValue = "";

  this.resolveNode("Country[1]").rawValue = "";

}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Enter this under the "Change" option of the script editor for the checkbox. just rename your fields appropriately. The second "If" will reset the fields if they accidently clicked it. Name[1] is the field you want the checkbox to fill. 'Name' is the original field.

if (this.rawValue == "1") {

  this.resolveNode("Name[1]").rawValue = this.resolveNode("Name").rawValue;

  this.resolveNode("Address[1]").rawValue = this.resolveNode("Address").rawValue;

  this.resolveNode("City[1]").rawValue = this.resolveNode("City").rawValue;

  this.resolveNode("State[1]").rawValue = this.resolveNode("State").rawValue;

  this.resolveNode("ZipCode[1]").rawValue = this.resolveNode("ZipCode").rawValue;

  this.resolveNode("Country[1]").rawValue = this.resolveNode("Country").rawValue;

}

if (this.rawValue == "0") {

  this.resolveNode("Name[1]").rawValue = "";

  this.resolveNode("Address[1]").rawValue = "";

  this.resolveNode("City[1]").rawValue = "";

  this.resolveNode("State[1]").rawValue = "";

  this.resolveNode("ZipCode[1]").rawValue = "";

  this.resolveNode("Country[1]").rawValue = "";

}