search

Home  >  Q&A  >  body text

Attempt to pass URL variable to iFrame on GoDaddy hosted website

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粉193307465P粉193307465276 days ago342

reply all(1)I'll reply

  • P粉824889650

    P粉8248896502024-02-27 00:15:37

    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")

    reply
    0
  • Cancelreply