Conditional Logic: conditions not working when form is previewed and when the form is embedded as iframe

  • Profile Image
    raledo
    Asked on November 07, 2017 at 11:26 AM

    I was making some changes to my forms today and noticed that Preview and Conditional logic is not working any more. Also when I embed the form in an iframe it is not working either.

    https://form.jotformeu.com/71432568954364

    I've tried two different accounts and different forms and the problem is the same.

    If I try to use the Fill Form button it does nothing.

    I have required fields and also some conditional logic and it does not seem to work. I can click Next on my form without filling in the required fields.

    When I get to the 5th page of my multi-step form I can not proceed. The Next button does nothing.

    The form seems to be working outside of Preview if I access it at its URL directly.

    Chris

  • Profile Image
    Welvin
    Answered on November 07, 2017 at 12:41 PM

    Our apologies. We are aware of the problem and our developers are currently working to resolve it. We will keep you posted. 

  • Profile Image
    Rose
    Answered on November 08, 2017 at 02:30 AM

    We are sorry for this inconvenience.

    The problem should be fixed now. Could you please check once again on your side and do let us know if you still encounter the same issue. On the other hand, we suggest you to clear your form caches before test it.  

    https://www.jotform.com/help/229-How-to-Clear-Your-Form-Cache

    Thank you in advance for your understanding and cooperation. 

  • Profile Image
    chrdunne
    Answered on November 08, 2017 at 06:15 AM

    Hi

    Initially the problem appeared to be fixed and in Preview mode I can use Fill Form and Conditional Logic appears to be working.

    On my website I want to pass a parameter to the form - parameter is called source.

    So my URL looks like 

    https://form.jotformeu.com/73112398154354?source=acmp

    If I go to this link, everything appears to be working correctly. But I want to dynamically generate this as the source parameter may be different depending on which page the user accesses the form from.

    So I am using PHP to generate the iframe code and append the parameter. Code at end of this message.

    I also have a HTML page with the iframe code (modified to include the parameter). When I visit the HTML page everything seems to work. But if I visit the php page, the form is presented but conditional logic and validation are not working. Also on the final page, the submit button does nothing and in the Javascript console I see errors.

    list.js:646 Configurable list ready {type: "ready", qid: "47", formID: "73112398154354", required: true, static: false, …}

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q124_whoIs' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q23_tellUs' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q125_whenYour125' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q126_pleaseProvide[addr_line1]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q126_pleaseProvide[addr_line2]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q126_pleaseProvide[city]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q126_pleaseProvide[state]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q126_pleaseProvide[postal]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q126_pleaseProvide[country]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q85_describeFire85' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q86_describeBurglar' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q112_pleaseSelect112[]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q112_pleaseSelect112[]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q112_pleaseSelect112[]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q112_pleaseSelect112[]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q112_pleaseSelect112[]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q112_pleaseSelect112[]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q112_pleaseSelect112[]' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q41_additionalInsured' is not focusable.

    73112398154354?source=ACMP&source=ACMP:1 An invalid form control with name='q42_additionalInsured42' is not focusable.


    If I remove the parameter everything seems to work ok.

    I've tried clearing caches. I copied the form to another account. But I'm still getting the same errors.

    My PHP code is

    <!DOCTYPE html>

    <html lang="en">

    <head>

    <meta charset="utf-8">

    <title>Main Program Quote Request</title>


    </head>

    <body>


    <?php


    $source = $_GET['source']; 

    echo '<iframe

    id="JotFormIFrame-73112398154354"

    onload="window.parent.scrollTo(0,0)"

    allowtransparency="true"

    src="https://form.jotformeu.com/73112398154354?source='.$source.'"

    frameborder="0"

    style="width: 1px;

    min-width: 100%;

    height:8200px;

    border:none;"

    scrolling="no">

    </iframe>

    <script type="text/javascript">

    var ifr = document.getElementById("JotFormIFrame-73112398154354");

    if(window.location.href && window.location.href.indexOf("?") > -1) {

      var get = window.location.href.substr(window.location.href.indexOf("?") + 1);

      if(ifr && get.length > 0) {

        var src = ifr.src;

        src = src.indexOf("?") > -1 ? src + "&" + get : src  + "?" + get;

        ifr.src = src;

      }

    }

    window.handleIFrameMessage = function(e) {

      var args = e.data.split(":");

      if (args.length > 2) { iframe = document.getElementById("JotFormIFrame-" + args[2]); } else { iframe = document.getElementById("JotFormIFrame"); }

      if (!iframe)

        return;

      switch (args[0]) {

        case "scrollIntoView":

          iframe.scrollIntoView();

          break;

        case "setHeight":

          iframe.style.height = args[1] + "px";

          break;

        case "collapseErrorPage":

          if (iframe.clientHeight > window.innerHeight) {

            iframe.style.height = window.innerHeight + "px";

          }

          break;

        case "reloadPage":

          window.location.reload();

          break;

      }

      var isJotForm = (e.origin.indexOf("jotform") > -1) ? true : false;

      if(isJotForm && "contentWindow" in iframe && "postMessage" in iframe.contentWindow) {

        var urls = {"docurl":encodeURIComponent(document.URL),"referrer":encodeURIComponent(document.referrer)};

        iframe.contentWindow.postMessage(JSON.stringify({"type":"urls","value":urls}), "*");

      }

    };

    if (window.addEventListener) {

      window.addEventListener("message", handleIFrameMessage, false);

    } else if (window.attachEvent) {

      window.attachEvent("onmessage", handleIFrameMessage);

    }

    </script>';

    ?>


    </body>

    </html>