SOLVED

Re: onMatch JS Function for list of countries

Go to solution
Liz_Nguyen1
Level 2

onMatch JS Function for list of countries

We worked with a third party for form shortening and now we're at a stage where we need to modify their existing code they setup for us to include an onMatch function for a list of countries, where as if country is a match for any of the ones in our list, the form should expand regardless. They provided us with one country example, but we need to expand it to include others. Does anyone know how we can modify this part of the code so we can include more than just Italy?

 

if (!window._zi_fc) {window._zi_fc = {}}
window._zi_fc.onMatch = (data) => {
   if (data.country == 'Italy') {

      console.log('User located in Italy!');

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jo_Pitts1
Level 10 - Community Advisor

Re: onMatch JS Function for list of countries

@Liz_Nguyen1 ,

try something like this:

if (!window._zi_fc) {window._zi_fc = {}}
window._zi_fc.onMatch = (data) => {
   const fullFormCountries = ["Italy", "Germany", "France"]
   if (fullFormCountries.includes(data.country)) {
      console.log('User located in a full form country');

 

Regards

Jo

View solution in original post

5 REPLIES 5
Jo_Pitts1
Level 10 - Community Advisor

Re: onMatch JS Function for list of countries

@Liz_Nguyen1 ,

try something like this:

if (!window._zi_fc) {window._zi_fc = {}}
window._zi_fc.onMatch = (data) => {
   const fullFormCountries = ["Italy", "Germany", "France"]
   if (fullFormCountries.includes(data.country)) {
      console.log('User located in a full form country');

 

Regards

Jo

SanfordWhiteman
Level 10 - Community Moderator

Re: onMatch JS Function for list of countries

(Parenthetically, one wonders why the 3rd party wouldn’t give you a little more help on this, if they developed the code recently!)

Jo_Pitts1
Level 10 - Community Advisor

Re: onMatch JS Function for list of countries

@SanfordWhiteman, quite.

 

I was feeling generous rather than contentious (I know.. strange), so I just gave the answer rather than pushing back. 🙂

Liz_Nguyen1
Level 2

Re: onMatch JS Function for list of countries

Ah, I should have been clearer in that. We worked with them previously to develop it. When reaching out for assistance, no responses, like crickets. So I thought I would try the community to see if anyone else had some insight to help. I know I am reaching at this point, but was hoping for some guidance.

Jo_Pitts1
Level 10 - Community Advisor

Re: onMatch JS Function for list of countries

@Liz_Nguyen1 ,

hopefully the guidance provided has got you over the line?

 

Cheers

Jo