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

    How can i create a light box jotform with cookie check

    Asked by clicksem on December 23, 2011 at 08:34 PM

    Hi,

    Reading the forum I have prepared a jotform with light box which is loading automatically when a visitor enter the site :

    <html> <head< </head>

    <body onload="document.getElementById('lightbox-13543810253').click()">
    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'13543810253',
    base:'http://www.jotform.com/',
    windowTitle:'Contact us',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:2,
    height:600,
    width:700
    });
    </script>
    <input id="lightbox-13543810253" style="display:none" type="submit" value="lightbox" >

    </body> </html>

    but i want this light box to pop up only once for every browser session. I've tried to entegrate some cookies with it but couldn't make it work.

    can you please help me to add a cookie to make it work only once for a browser session.

    thanks a lot

    olcay

    check session height cookie lightbox onload
  • Profile Image
    JotForm Support

    Answered by liyam on December 24, 2011 at 03:55 AM

    I don't think this is possible, but let me pass this inquiry to our development team.  They will respond to this thread as soon as they are available.

    Thank you for your patience.

  • Profile Image

    Answered by olcay on December 24, 2011 at 10:42 AM

    i guess without body on load tag light box can pop up on load like this:

     

    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'135********',
    base:'http://www.jotform.com/',
    windowTitle:'DR. MUSTAFA ERARSLAN SORULARINIZI CEVAPLIYOR!',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:600,
    width:700,
    openOnLoad:true
    });
    </script>

     

    so is it possible to embed a cookie to enable once in one browser session with the above code.

     

    thanks in advance.

  • Profile Image

    Answered by clicksem on December 24, 2011 at 11:25 AM

    the cookie i'm trying to entegrate with light box is below:

    <script type = "text/javascript">

    function setCookie(isName,isVal) {
    document.cookie = isName + "=" + isVal + ";expires="  + "path=/";
    }

    function getCookie(isName){
    cookieStr = document.cookie;
    startSlice = cookieStr.indexOf(isName+"=");
    if (startSlice == -1) {return false}
    endSlice = cookieStr.indexOf(";",startSlice+1);
    if (endSlice == -1){endSlice = cookieStr.length}
    isData = cookieStr.substring(startSlice,endSlice)
    isValue = isData.substring(isData.indexOf("=")+1,isData.length);
    return isValue;
    }

    function dispCookie(isName) {
    nValue = getCookie(isName);
    if (nValue) {
    alert ("Cookie Found");  // so do nothing
    }

    else {
    alert ("The Cookie was not found");

    //so add the code hereto cause Lightbox to appear


    }
    }

    </script>

     

    and the light box code for jotform is like this:

     

    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'13543810253',
    base:'http://www.jotform.com/',
    windowTitle:'FORM TITLE!',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:600,
    width:700,
    openOnLoad:true
    });
    </script>

     

    unfourtanetly the two scripts are javascript and i can't blend them...

  • Profile Image
    JotForm Founder

    Answered by aytekin on December 26, 2011 at 02:04 AM

    You should probably disable the openOnLoad, and instead trigger the lightbox only when you find no cookies on the browser. 

  • Profile Image

    Answered by clicksem on December 26, 2011 at 09:13 AM

    Aytekin bey merhabalar,

    cevabınız için teşekkürler, ancak benim yapamadığım şey de bu tetikleme işi. cookie kodunda

     

    //so add the code hereto cause Lightbox to appear

     

    yazan yere, lightbox kodunu eklemem gerekiyor sanırım ama ikiside javascript ve oraya nasıl kodu ekleyeceğimi bilemiyorum.

     

    <script type = "text/javascript">

    function setCookie(isName,isVal) {
    document.cookie = isName + "=" + isVal + ";expires="  + "path=/";
    }

    function getCookie(isName){
    cookieStr = document.cookie;
    startSlice = cookieStr.indexOf(isName+"=");
    if (startSlice == -1) {return false}
    endSlice = cookieStr.indexOf(";",startSlice+1);
    if (endSlice == -1){endSlice = cookieStr.length}
    isData = cookieStr.substring(startSlice,endSlice)
    isValue = isData.substring(isData.indexOf("=")+1,isData.length);
    return isValue;
    }

    function dispCookie(isName) {
    nValue = getCookie(isName);
    if (nValue) {
    alert ("Cookie Found");  // so do nothing
    }

    else {
    alert ("The Cookie was not found");

    //so add the code hereto cause Lightbox to appear

    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'12312312312',
    base:'http://www.jotform.com/',
    windowTitle:'FORM TITLE!',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:600,
    width:700,
     
    });
    </script>



    }
    }

    </script>

     

    yani yukarıdaki gibi olmayacağı kesin ama nasıl birleştirileceği hakkında yardıma ihtiyacım var

  • Profile Image
    JotForm Support

    Answered by fxr on December 28, 2011 at 02:22 PM

    Hi clicksem, are you are able post your response above in English?

    Maybe someone in the support team will be able to help you while Aytekin is out of office.

     

    thanks.

  • Profile Image

    Answered by clicksem on December 29, 2011 at 07:44 AM

    The problem is that i can't trigger the code within the cookie code since both of them are in javascript form and i can't blend them. i'm not a coder and need help to mix the codes which are working good independently. 

    //so add the code hereto cause Lightbox to appear

     

    the above place is the place where i should insert the light box code but how? both codes are below mixed but ofcourse not working.

     

    <script type = "text/javascript">

    function setCookie(isName,isVal) {
    document.cookie = isName + "=" + isVal + ";expires="  + "path=/";
    }

    function getCookie(isName){
    cookieStr = document.cookie;
    startSlice = cookieStr.indexOf(isName+"=");
    if (startSlice == -1) {return false}
    endSlice = cookieStr.indexOf(";",startSlice+1);
    if (endSlice == -1){endSlice = cookieStr.length}
    isData = cookieStr.substring(startSlice,endSlice)
    isValue = isData.substring(isData.indexOf("=")+1,isData.length);
    return isValue;
    }

    function dispCookie(isName) {
    nValue = getCookie(isName);
    if (nValue) {
    alert ("Cookie Found");  // so do nothing
    }

    else {
    alert ("The Cookie was not found");

    //so add the code hereto cause Lightbox to appear

    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'12312312312',
    base:'http://www.jotform.com/',
    windowTitle:'FORM TITLE!',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:600,
    width:700,
     
    });
    </script>



    }
    }

    </script>

     

    thanks in advance.

    olcay 

  • Profile Image
    JotForm Support

    Answered by fxr on December 29, 2011 at 09:17 AM

    Perhaps the best way to approach this problem is use php to set and check for your cookies. 

    Then add the JotForm javascript to the webpage with php should the cookie not be set. 

    Take this example code: (I used the JotForm code you were using above, seems the form is now deleted) 

    http://pastie.org/3090452

    This gives this result: http://pamppi.info/jotform-testing/cookie-test/cookie.php

     

    Have a look at that. Let me know if any you need any clarification on any of it.

    Do you think you would be able implement something like that? 

  • Profile Image

    Answered by clicksem on December 31, 2011 at 12:37 PM

    thanks fxr,

    code worked perfect...

    happy new year for you all...

  • Profile Image
    JotForm Support

    Answered by abajan on December 31, 2011 at 07:01 PM

    Very glad my colleague's solution fit your needs.

    Cheers and Happy New Year! :)

  • Profile Image

    Answered by elgenaro on January 12, 2012 at 10:15 AM

    @fxr: How do I add that to an existing page?

  • Profile Image
    JotForm Support

    Answered by fxr on January 12, 2012 at 11:29 AM

    @elgenaro, 

    Please review this User Guide Entry, it may help your understanding of where this code needs to go. 

    Let me know if you have further questions. 

  • Profile Image

    Answered by elgenaro on January 13, 2012 at 04:28 AM

    Thanks a lot! It looks very very clear, thanks! :)

  • Profile Image

    Answered by Tyler on April 21, 2013 at 12:31 PM

    How can this be added to the body of an html and still function? I am unable to access html and head. How can I do a cookie check/php within the body and still open once per browser session?

     

  • Profile Image

    Answered by moonzkie on April 21, 2013 at 02:18 PM

    @ Tyler (rctfavre@yahoo.com)

    Hi,

    This guide may help you to understand on how to embed your form on an existing page: http://www.jotform.com/help/140-Using-cookies-to-automatically-open-a-lightbox-form-once-per-browser-session

    We'd appreciate if you could open a new thread for your issue so we can assist you better.

    Thank you.