Multiple Form Embeds on same page / Losing Parameters

  • Profile Image
    jorein
    Asked on March 05, 2012 at 07:21 PM

    Hi,

    I have some conditional logic that inserts either one or two jot forms on the same page.  If both conditions are met I am for some reason losing my ability to pass parameters to my jotform fields in the first form.   It has something to do with the embedding of multiple scripts because if I just add source code instead of the script call in the second condition then everything seems to work.

    Here is the code (Thanks in advance for any help you can offer):

     

     

    Prior to Logic Name = {{ customer.name }}

     

    {% assign local_pickup = false %}

    {% for shipping_method in shipping_methods %}

    {% if  shipping_method.price == 0 %}

      {% assign local_pickup = true %}

    {% endif %}

    {% endfor %}

     

    {% assign need_art_uploaded = false %}

    {% for item in line_items %}

    {% if item.product.type == 'Art by You!' %}

      {% assign need_art_uploaded = true %}

    {% endif %}

    {% endfor %}

     

    {% if need_art_uploaded %}

     

    In art need uploaded condition = {{ customer.name }}

     

    <script type="text/javascript" src="//form.jotform.us/jsform/20591112494146?order={{ order_number }}&yourName={{ customer.name }}&email={{ customer.email }}&shopifyOrder={{ order_number }}&shopifyName={{ customer.name }}&shopifyEmail={{ customer.email }}"></script>

     

    {% endif %}

     

    Prior to local pickup condition = {{ customer.name }}

     

    {% if local_pickup %}

     

    local pickup condition met = {{ customer.name }}

     

    <script type="text/javascript" src="//form.jotform.us/jsform/20626058201140"></script>

     

    {% endif %}

     

  • Profile Image
    Mike_T
    Answered on March 05, 2012 at 07:54 PM

    Thank you for contacting us.

    Is there any way that you can use an iFrame embedding option instead? I hope it will solve the problem.

    Please let us know if you need any further assistance.

  • Profile Image
    jorein
    Answered on March 05, 2012 at 08:00 PM

    Hi Mike,

    I tried the iFrame and it seems to solve the problem in terms of my losing my parameters when having multiple form embeds on the same page.  I wish I understood what was causing the issue, for my own personal education.  The work around is helpful though so many thanks!

    -John

  • Profile Image
    liyam
    Answered on March 05, 2012 at 09:53 PM

    Hello John.  I don't have a clear answer for this, but in theory, this is caused by the code in the javascript for embedding the form.  Once you have loaded another form, the 1st script that accepts the form values gets cleared while it starts the other script.  And since the parameters are exclusive to the 1st script, it gets cleared as well.

    When trying to load the forms hierarchy like this:

    <script type="text/javascript" src="//form.jotform.us/jsform/20591112494146?order={{ order_number }}&yourName={{ customer.name }}&email={{ customer.email }}&shopifyOrder={{ order_number }}&shopifyName={{ customer.name }}&shopifyEmail={{ customer.email }}"></script>

    <script type="text/javascript" src="//form.jotform.us/jsform/20626058201140"></script>

    You will notice that the form is empty.  Now when you try to switch its position, you will notice that the form with fields is filled.

    Then when you try adding the parameters to the address bar, the parameters will act something some global variables so regardless of the forms' positions, it will find the parameters and fill it up.

    I hope this sheds some light to your concerns.

  • Profile Image
    liyam
    Answered on March 05, 2012 at 10:32 PM

    In addition, I just noticed in using IE, that there starts to be a conflict with loading two forms by embedding via javascript code.  So this is causing the error.  The best solution for this is either copying the source code and placing it in your web page but using only one javascript reference, or using iFrame as suggested by Mike_T above