Pass querystring parameters to form embedded in Wordpress

  • valutech
    Asked on March 31, 2020 at 5:58 PM

    We have a form that is embedded on a WordPress site using the [embed] directive.


    When the parent page is rendered, there are querystring parameters provided that need to be passed into the form that is embedded.  How do I pass the values to the embedded form?  I don't have the ability to modify the URL of the iFrame because it is rendered by the [embed] directive.  


    Thank you

  • jonathan
    Replied on March 31, 2020 at 8:08 PM

    Please try using the iframe embed code of the form instead on your Wordpress website.

    Guide : Getting the Form iFrame Code

    The best way to get the URL with all the fields to be prepopulated is using the prepopulate app form here: http://prepopulate.jotform.io/.

    Once you get the URL with the variables prepopulated, you just need to add this URL in the embed method that you are using, so for example, if you are using the iFrame method you just need to update the URL, just replace it with the new URL with the variables.

    Example:

    <iframe id="JotFormIFrame" onDISABLEDload="window.parent.scrollTo(0,0)" allowtransparency="true" src="//form.jotformpro.com/form/123456787?OrderID=23232" frameborder="0" style="width:100%; height:4083px; border:none;" scrolling="no"></iframe>

    The highlighted value, is the value that you want to insert into the field, you need to pass the values over the URL where the form is embedded on.

    Let us know if you need further assistance.



  • valutech
    Replied on March 31, 2020 at 10:09 PM

    Thanks for your response.  This works fine if we know the data to be pre-populated at the time we embed the form.  The values that are provided on the querystring will be dynamic and will not be known at build time.  So we cannot embed the URL with the values populated in the iFrame source; the querystring must be passed to the iframe at the time the page and form is loaded.

    Thanks



  • valutech
    Replied on March 31, 2020 at 10:17 PM

    Update: I solved this by using the Wordpress plugin "Pass URL Parameters to Embedded iFrame".  

    By assigning a specific ID value to the <script> tag that renders the iframe, the plugin will parse the querystring parms on the page and assign them to the SRC attribute on the iframe.  

     

  • Elton Support Team Lead
    Replied on April 1, 2020 at 2:44 AM

    Happy to know that you've managed to get this resolved and thanks for sharing your workaround.

    Regards!