Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Checkbox - Same as Street Address

Avatar

Level 1

I've tried searching through the discussions for an answer to this question, but I haven't found one, so I'm hoping it will be a quick, simple answer. And thanks in advance to anyone willing to help.

I'm creating a form which asks for the street address and the mailing address of the applicant. I've included a checkbox for the applicant to use if their mailing address is the same as their street address. I've added the following script to the mouseUp event of the checkbox:

if (getField("SameAsStreet").value=="Yes")

getField("MailingAddress").value = getField("StreetAddress").value

else getField("MailingAddress).value = "";

This script does not work when I enter data into the street address field then check the checkbox.

Any ideas?

1 Accepted Solution

Avatar

Correct answer by
Level 1

Try this one in Script Editor:

Set code in SameAsStreet(CheckBox)::change event

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

     this.resolveNode("MailingAddress").rawValue = this.resolveNode("StreetAddress").rawValue;

}

else {

     this.resolveNode("MailingAddress").rawValue = "";

}

Let me know your comments for the same.

Thanks,

Rahul Pathak

View solution in original post

3 Replies

Avatar

Level 1

I've also tried this script:

if (event.target.value != "1") {

this.getField("MailingAddress").value = this.getField("StreetAddress").value;

} else {

this.getField("MailingAddress").value = "" ;

This script does not work either.

Anybody?

Avatar

Correct answer by
Level 1

Try this one in Script Editor:

Set code in SameAsStreet(CheckBox)::change event

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

     this.resolveNode("MailingAddress").rawValue = this.resolveNode("StreetAddress").rawValue;

}

else {

     this.resolveNode("MailingAddress").rawValue = "";

}

Let me know your comments for the same.

Thanks,

Rahul Pathak

Avatar

Level 1

Thank you, Rahul. That works perfectly. Very, very much appreciate your assistance.