How can i create a light box jotform with cookie check

  • Profile Image
    clicksem
    Asked 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

  • Profile Image
    liyam
    Answered 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
    olcay
    Answered 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
    clicksem
    Answered 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
    aytekin
    Answered 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
    clicksem
    Answered 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
    fxr
    Answered 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
    clicksem
    Answered 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
    fxr
    Answered 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
    clicksem
    Answered on December 31, 2011 at 12:37 PM

    thanks fxr,

    code worked perfect...

    happy new year for you all...

  • Profile Image
    abajan
    Answered on December 31, 2011 at 07:01 PM

    Very glad my colleague's solution fit your needs.

    Cheers and Happy New Year! :)

  • Profile Image
    elgenaro
    Answered on January 12, 2012 at 10:15 AM

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

  • Profile Image
    fxr
    Answered 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
    elgenaro
    Answered on January 13, 2012 at 04:28 AM

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

  • Profile Image
    Tyler
    Answered 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
    moonzkie
    Answered 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.