Attempt to pass URL variable to iFrame on GoDaddy hosted website
P粉193307465
P粉193307465 2024-02-26 09:00:05
0
1
395

We are currently using CognitoForms to host forms on our public facing website. We need to pass a unique field called "Barcode" for each user. I wish we could do something like https://ourwebsite.com/client?barcode=921371 but that doesn't seem to work at all.

After discussion with CognitoForms support, they provided the following script. However, it doesn't work in any browser. The browser console doesn't show any obvious errors either. Is there anything obviously incorrect here?

<iframe src="https://www.cognitoforms.com/f/ourformid/1" style="border:0;width:100%;" height="576">    </iframe>

<script src="https://www.cognitoforms.com/f/iframe.js"></script>

<script>
   function getQueryStringParam(parameter) {
      var queryString = window.location.search;
      var urlParams = new URLSearchParams(queryString);
      return urlParams.get(parameter);
   }
   Cognito.prefill({ "Barcode": getQueryStringParam('Barcode') });
</script>

I've tried passing parameters in different formats, including JSON. I've also checked the browser debug logs but can't find any errors - the field doesn't get populated at all.

P粉193307465
P粉193307465

reply all(1)
P粉824889650

Your example link references "barcode" as a query parameter:

https://ourwebsite.com/client?barcode=921371

Script reference "barcode"

Cognito.prefill({ "Barcode": getQueryStringParam('Barcode')

Is this error related to wrong capitalization? ("barcode"!="barcode")

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template