What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Don't show form using java if user has completed it in past x number of days?

    Asked by precisionsails on October 12, 2013 at 07:37 PM

    Using java or ajax is it possible to use cookies to not show a light box form if a user has already completed the form?

    I have seen the php and asp methods but my shopping cart will not allow any server side scripting and therefore these methings do not work.

    I need to find a method using java to do this.

    Can it last longer than just a single browser session?  How about a coockie that lasts 30 days or so?

    style size session font
  • Profile Image
    JotForm Support

    Answered by EltonCris on October 12, 2013 at 08:14 PM

    Hi,

    We'll see if we can come up a workaround for you.

    We'll get back to you as soon as we found a solution.

    Thanks!

  • Profile Image

    Answered by matt on October 12, 2013 at 09:04 PM

    I tried using the tutorial located here:
    http://sicanstudios.com/post/set-cookies-javascript/

    It seems however that there is a conflict with the loading of jquery.  This script requires the following call to jquery that stops the lighbox from working:

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> 


    You can see my integration of this located at link below.

    http://www.precisionsailloft.com/Abbott-33-Sails-for-Sale-cu-s/1248.htm

     

    The cockie works but it kills the jotform lightbox

     

     

  • Profile Image
    JotForm Support

    Answered by EltonCris on October 12, 2013 at 10:51 PM

    Hi Matt,

    That's great!

    To fix the conflict, just declare noConflict on your cookie script. Just do it like this:

     

    <script type="text/JavaScript">

    var $j = $.noConflict();

    $j(document).ready(function() {

        $j('.letushelp h1').css("display", "block");

        $j('.letushelp h3').css("display", "none");

         var cookie_mesage = $j.cookie('welcome');

         if (cookie_mesage == 'hide') {

            $j('.letushelp h1').css("display", "none");

            $j('.letushelp h3').css("display", "block");

        };

        $j.cookie('welcome', 'hide', {expires: 7 });

     });

    </script>

    More info: http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/

    Let us know if this doesn't help. Thanks!

  • Profile Image

    Answered by matt on October 12, 2013 at 11:33 PM

    Thanks, this has solved the jquery confilic but it seems the code I got from the tutorial doesnt quite do what i expected it to do.

    It seems that it hides the specific element on the page but the java lighbox code is still getting executed even though the page element is hidden. I think i simply need to change the script to remove the specific page element rather than hide the element.

    How would i modify this script to remove the items between the <h1> tags instead of just hidding that element from displaying on page?

    Im thinking instead of ("display", "none"); it needs to be something else. Im not sure what though?

     

    Any help here is greatly appreciated!

  • Profile Image

    Answered by Cesar on October 13, 2013 at 12:09 AM

    The (display:none) should render the page without the element as opposed to (visibility:hidden) which keeps the element on the page without actually removing it completely.

    We'll do our best to find a solution to the current behavior, this may take some time to try out some possible solutions. In any case, if we have an update on this, we will let you know through this thread. Thank you.

  • Profile Image

    Answered by matt on October 13, 2013 at 12:16 AM

    Could this be a matter of timing?

    What i mean by this is when i test it, i notice the element appears on the page then a second or so later it dissapears.

    Could it be that the code is being executed during this moment while its on page before it is removed from the page?

    I wonder how to speed / slow it down to stop this?

    Of course this may not be the issue at all just an observation.

  • Profile Image

    Answered by Cesar on October 13, 2013 at 12:46 AM

    This may be due to the way the page gets loaded and then rendered by the code. Unless one of my colleagues has a suggestion. I do believe this may very well be the how the code will render due to how the code is being embedded on the page.

  • Profile Image
    JotForm Support

    Answered by EltonCris on October 13, 2013 at 04:46 AM

    Hi Matt,

    Making the h1 tag to "display:none" alone will not actually stop the form from executing on your page. :)

    The reason why is that, on your lightbox code it is set to auto-popup everytime the page loads. To stop it from executing and in order for it to work with the cookie script, first you have to removed the onload code on your lightbox scripts. I have labelled it below.

     

    <script language="JavaScript">

    var delayseconds = 1;

        function pause() {

        myTimer = setTimeout('whatToDo()', delayseconds * 1000)

        }

       function whatToDo() {

    document.getElementById('lightboxdelay').click();

        }

    window.onload = pause; // <-----Remove this

    </script>

    ---------------------------

    Next, do not use "display:none" property, you can removed the h1 tag if you want then try your cookie conditions like this.

     

    <script type="text/JavaScript">

    var $j = $.noConflict();

    $j(document).ready(function() {

         var cookie_mesage = $j.cookie('welcome');

         if (cookie_mesage == 'hide') {

            $j('.letushelp h3').css("display", "block");

        }

        else{

        $j('.letushelp h3').css("display", "none");

        pause();

        };

        $j.cookie('welcome', 'hide', {expires: 7 });

     });

    </script>

    pause is the function name to call the lightbox (this is based on your lightbox script). If I've placed it on the wrong structure, feel free to correct it.

    Let us know if this doesn't work. Thanks!

  • Profile Image

    Answered by matt on October 13, 2013 at 12:17 PM

    This worked!! You guys are incredible.  I have never seen support like this for any product online before! Keep up the great work and thank you once again!

  • Profile Image

    Answered by jeanettebmz on October 13, 2013 at 03:12 PM

    Hello Matt

    I am very glad reading such praise towards our service, this is what really feeds our passion up to keep up the good work here at JotForm

    Cheers!

  • Profile Image

    Answered by matt on October 14, 2013 at 02:56 PM

    I tried making one additional change and it seems to have cuased another problem.  Likely not hard to fix.

    What i wanted to happen was for everyone that has seen the lightbox on future visits just show the embeded form above the products. It's much less intrusive. So i took the embeded form code and used it.  This works fine. The problem is i need to have this form pass the page url into the hidden field just like for the light box one.  To do this i followed the tutorials and credted the following code.

    <script type="text/javascript">
    document.write(" <script src=\"http://form.jotform.ca/jsform/32845595620258?pageaddress= " + window.location.href + " \"></ " + " script> ");
    </script> 
     

    Trouble is the script will not hide this code and instead runs it every time over ridding the light box. 

    I have put the code below and highlighted the part that seems to be causing the problem.  If this code is replaced with html everything works fine. It seems the java required to pass the page url is causing the issue.

     

    <div class="letushelp">

    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">

    new JotformFeedback({

    formId:'32845595620258',

    base:'http://jotform.ca/',

    iframeParameters: {

    'pageaddress': document.URL},

    windowTitle:'Let us help you.',

    background:'#FFA500',

    fontColor:'#FFFFFF',

    type:false,

    height:550,

    width:700,

    });

    </script>

     

    <a id="lightboxdelay" class="lightbox-32845595620258" style="cursor:pointer;color:blue;text-decoration:underline;"> </a>

     

    <script language="JavaScript">

    var delayseconds = 1;

        function pause() {

        myTimer = setTimeout('whatToDo()', delayseconds * 1000)

        }

       function whatToDo() {

    document.getElementById('lightboxdelay').click();

        }

    </script>

    <h3>

    <script type="text/javascript">
    document.write(" <script src=\"http://form.jotform.ca/jsform/32845595620258?pageaddress= " + window.location.href + " \"></ " + " script> ");
    </script>

    </h3>

    </div>

     

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script type="text/javascript" src="/v/vspfiles/content/cookie/cookie.js"></script>
     

    <script type="text/JavaScript">

     var $j = $.noConflict();

     $j(document).ready(function() {

         var cookie_mesage = $j.cookie('welcome');

         if (cookie_mesage == 'hide') {

            $j('.letushelp h3').css("display", "block");

        }

     

        else{

         $j('.letushelp h3').css("display", "none");

        pause();

         };

        $j.cookie('welcome', 'hide', {expires: 7 });

     });

     </script>

    <br><span style="font-weight: bold; font-size: 14pt;">Click on a sail below to customize options and view full pricing.</span>


  • Profile Image
    JotForm Support

    Answered by Mike_T on October 14, 2013 at 03:28 PM

    Can you try to call different forms on the lightbox and page to see if that makes any difference?

  • Profile Image

    Answered by matt on October 14, 2013 at 04:45 PM

    yes, if i call the regular embeded code:

    <script type="text/javascript" src="http://form.jotform.ca/jsform/32845595620258"></script>

    everything works fine... except i cant pass the page url to the form.

    As soon as i use the java version that passes the page url I have a problem.


    Working script that doesnt pass page url:
    http://www.precisionsailloft.com/Abbott-22-Sails-for-Sale-cu-s/1245.htm

    Not working script that passes page url but doesnt have light box:
    http://www.precisionsailloft.com/Abbott-33-Sails-for-Sale-cu-s/1248.htm

     

     

  • Profile Image

    Answered by jeanettebmz on October 14, 2013 at 07:57 PM

    What Mike suggests you is to try a different form to see if it doesn't conflict rather than calling the same form on both the page and the lightbox

  • Profile Image

    Answered by matt on October 15, 2013 at 11:15 AM

    I have updated the page below to use two different forms in the code. It did not solve the problem.
    http://www.precisionsailloft.com/Abbott-33-Sails-for-Sale-cu-s/1248.htm

  • Profile Image

    Answered by EliezerN on October 15, 2013 at 12:46 PM

    @Matt

    Thanks for informing us that calling two different forms does not work. We will make a deeper investigation to find why/how the script to pass the URL to the hidden field is causing you this issue.

    We'll update later once we get a solution.

    Thanks