Reply To: Using JavaScript to pull information

Home Forums Quform WordPress Using JavaScript to pull information Reply To: Using JavaScript to pull information

#36455
GOMLP
Participant

Hi Ally,

Sorry for the delay in responding. The code worked good, however I’ve been trying to play around with it a bit more to extend the functionality and I’m not having much luck.

My goal is to allow the customer to enter their unique invitation code on the first page and when proceeding to the second page of the form it will look up the customer’s information based on this unique invitation code so I can use this looked up information in a custom HTML header text for display, while also pre populating form fields to confirm that their phone number, email and mailing addresses information is correct. If their information needs to be updated the customer can either click on a check box to either enable editing of the information field(s) or simply overwrite the looked up information for submission.

But in either case I want to be able to look up this information for; 1) Customizing an HTML welcome header on the second page and 2) populating form fields with the looked up information.

jQuery(function ($) {
var contactInfo = {
’11’: {
firstName: ‘Todd’,
lastName: ‘Rose’,
eMailAddress: ‘toddl@gomlp.net’,
phoneNumber: ‘(902) 835-2400’,
companyName: ‘Maritime Labels & Packaging’,
mailingStreetAddress: ‘9172 Highway 14’,
mailingCity: ‘Milford’,
mailingProvince: ‘Nova Scotia’,
mailingPostalCode: ‘B0N 1Y0’,
shippingAddress: ‘9172 Highway 14’,
shippingCity: ‘Milford’,
shippingProvince: ‘Nova Scotia’,
shippingPostalCode: ‘B0N 1Y0′
},
’22’: {
firstName: ‘Paul’,
lastName: ‘Sproule’,
eMailAddress: ‘paul@gomlp.net’,
phoneNumber: ‘(902) 835-2400’,
companyName: ‘Maritime Labels & Packaging’,
mailingStreetAddress: ‘9172 Highway 14’,
mailingCity: ‘Milford’,
mailingProvince: ‘Nova Scotia’,
mailingPostalCode: ‘B0N 1Y0’,
shippingAddress: ‘9172 Highway 14’,
shippingCity: ‘Milford’,
shippingProvince: ‘Nova Scotia’,
shippingPostalCode: ‘B0N 1Y0′
},
’33’: {
firstName: ‘Kyle’,
lastName: ‘Tomblin’,
eMailAddress: ‘kyle@gomlp.net’,
phoneNumber: ‘(902) 835-2400’,
companyName: ‘Maritime Labels & Packaging’,
mailingStreetAddress: ‘9172 Highway 14’,
mailingCity: ‘Milford’,
mailingProvince: ‘Nova Scotia’,
mailingPostalCode: ‘B0N 1Y0’,
shippingAddress: ‘9172 Highway 14’,
shippingCity: ‘Milford’,
shippingProvince: ‘Nova Scotia’,
shippingPostalCode: ‘B0N 1Y0’
},
};

$(‘.quform-field-12_7’).on(‘change’, function () {
var value = $(this).val();

if (value && contactInfo[value]) {
var contact = contactInfo[value];

$(‘.quform-element-12_38 .quform-spacer’).html(contact.firstName);
$(‘.quform-element-12_36 .quform-spacer’).html(substrate.lastName);
$(‘.quform-element-14_1065 .quform-spacer’).html(substrate.adhesive);
$(‘.quform-element-14_1069 .quform-spacer’).html(substrate.min_app_temp);
$(‘.quform-element-14_1075 .quform-spacer’).html(substrate.service_temp_range);
}
});
});

Be inspired. © 2022 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy