You are viewing limited content. For full access, please sign in.



"State" Field Not Automatically Filled When Duplicating Address Field by Checkbox

asked on August 10

Since there are many instances that forms will require two address fields and the address fields will frequently match (e.g., mailing address and street address, shipping address and billing address, etc.), it may be more efficient to duplicate the address field by checking a box.  As you can see from the screenshot, all of the street address fields are automatically filled with the specified mailing address, except for the state field, which has been modified for a drop-down list for the state information.

Below is the code that modifies the state field and automatically fills the street address fields.  Any ideas why the state field is not being filled and how the code should be changed?

Duplicating Address Field by Checking a Box.PNG
JavaScript for Duplicating Address Field by Checkbox.PNG
0 0


replied on August 10

Hi John,

Since you have changed the State field from "input" element to "select" element, $('.MailingAddress').find('input') will not find this field, so it is not updated.

Find select element and update its value:



0 0


replied on August 14

Thanks, Rui.  That worked!  Below is the entire code that automatically fills in the "Street Address" when the box is checked along with a screenshot of the two address fields.

JavaScript for Automatically Filled Address Fields.PNG
Automatically Filled Street Address.PNG
0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.