dynamic php variable to lightbox

  • dr770
    Answered on December 19, 2011 06:31 AM

    Hi toghether,

    i would like to provide a dynamic php variable (let say $ref) to lightbox, and be able to get the value per email.

    advice appreciated

    thanks a lot

    dovid

  • NeilVicente
    Answered on December 19, 2011 07:27 AM

    I am not sure if I get what exactly it is that you want to achieve. What is the purpose of the php variable that you intend to integrate with the form? Perhaps a clear point by point explanation will help us understand your goal better.

    Would you mind showing us the page in which the form you're referring to is embedded?

  • dr770
    Answered on December 19, 2011 07:37 AM

    thanks for fast responce.

    here:

    http://fj.drhost.us/index.php?route=product/product&path=20_26&product_id=51

    store owner should now from wich product the request came. I have product_id variable, and i wont to forward it to lightbox.

    thanks a lot

  • NeilVicente
    Answered on December 19, 2011 08:09 AM

    Here is what you can instead. Capture the product page URL and pass it on a hidden box field on the form by using the iframeParameters variable for the lightbox script.

    Insert a hidden box on the form first. The hidden box can be found under the Power Tools section

    dynamic php variable to lightbox Image 1 Screenshot 0

    Name it to something like "referrer" or "product_url".

    Copy the code below and paste it on your form's lightbox script, right after the width section. Be sure to enter a comma right after the value of width.

    ,
    iframeParameters: {
    'product_url':window.location.href
    }

    For example:

    <script src="//german.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'13513418549',
    base:'http://german.jotform.com/',
    windowTitle:'FashionJewProduct',
    background:'#000',
    fontColor:'#FFFFFF',
    type:2,
    height:500,
    width:700,
    iframeParameters: {
    'product_url':window.location.href
    }
    });
    </script>

  • vistacollege
    Answered on January 27, 2012 03:20 PM

    I tried .. not working. Anything I'm missing here?

     

    On the hidden field:

    Created it and named it: source

    On the html code, it returns:

    <input type="hidden" class="form-hidden" value="" id="input_12" name="q12_source" />

     

    So on the script, I tried:

    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'xxxxxxxxxxxx',
    base:'http://www.jotform.com/',
    windowTitle:'mytitle',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:500,
    width:300,
    iframeParameters: {
    'input_12':'<?php echo $mySource ?>'
    }
    });
    </script>

     

    I've also tried:

    'q12_source':'<?php echo $mySource ?>'

    'q12_source':<?php echo $mySource ?> ----> if value without single quote, lightbox doesn't fire

    'source':'<?php echo $mySource ?>'

  • vistacollege
    Answered on January 27, 2012 04:26 PM

    also tried passing the php value into a javascript variable first.. no go.

    var mySource = "<?php echo $mySource ?>";

    new JotformFeedback({

    ........

    iframeParameters: {
    'q12_source':mySource
    }

  • liyam
    Answered on January 27, 2012 10:07 PM

    I would like to verify, is that the actual php code in it? I noticed that you're missing a semi-colon at the end of every variable after making an echo. I'm guessing that's why it's not passing the value. 

  • vistacollege
    Answered on February 14, 2012 10:44 AM

    Yes, never had issues with one liner php code without semi-colon. Nevertheless, added them and still no go... any support mailbox i can get assistance from?

  • liyam
    Answered on February 14, 2012 12:05 PM

    Sorry, I failed to notice your parameters.  Please do not include q12_ in it. So it should look like this:

    iframeParameters: {
    'source': '<?php echo $my_var ?>'
    }

    This should work fine.

    If this still does not work, please let us know.

    Thanks.

  • vistacollege
    Answered on February 14, 2012 01:15 PM

    Very nice.. works! thanks!!

  • LDMedia
    Answered on February 18, 2012 02:19 AM
  • LDMedia
    Answered on February 18, 2012 02:19 AM

    Thought I'd share some tips for anyone trying to use multiple hidden fields or trying to redirect users back to the page on which a jotform was activated.

    To collect the required data via hidden fields I used the commands:

     $_SERVER['HTTP_HOST'] -  To get the domain i.e. www.yoururl.com

     $_SERVER['REQUEST_URI'] - To get the path i.e. www.yoururl.com/index.php

     $_SERVER['QUERY_STRING'] - To get the query string i.e. www.yoururl.com/index.php?variable=value

    This method is useful if you are passing user identification through your url as a ?variable and want to send a user back to a page with dynamic content that depends on this.

    In my form I have three hidden fields 'refURL', 'Path', and 'String'. By prefilling these three fields with php $_Server commands (helpfully detailed here: http://www.learnphponline.com/php-basics/how-to-find-the-current-url-in-php#domain) I was able to reconstruct the full url of the page on which my lightbox was opened.

    Lightbox script:

    <script src="//www.jotform.net/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'XXXXXXXXXXX',
    base:'http://www.jotform.net/',
    windowTitle:'Test Geocode',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:500,
    width:700
    ,
    iframeParameters: {'refurl': '<?php echo $_SERVER['HTTP_HOST']?>', 'path': '<?php echo $_SERVER['REQUEST_URI'] ?>','string': '<?php echo $_SERVER['QUERY_STRING']?>'}

    });
    </script>
    <a class="lightbox-20471343209" style="cursor:pointer;color:blue;text-decoration:underline;">Form title here</a><br>

    Fun fact: Jotform will not POST any prefilled data to a field called 'url'. I found this out the long and frustrating way. Call your field something else, in this case I have used 'refurl'.

    Finally, to reconstruct the referring url that your form was launched on you can concatenate all three fields:

    $formlocation = "http://" . $refurl . $path . $string ;

    echo "<a href=$formlocation>Back to new submission page</a>";

  • tpclickz
    Answered on March 01, 2013 03:57 AM

    I'm trying to do the same as vistacollege above, but still unable to get it working.

    This is my code so far:

    <script src="//cdn.jotfor.ms/min/g=feedback2" type="text/javascript">

    new JotformFeedback({

    formId:'30591066142953',

    base:'http://jotformpro.com/',

    windowTitle:'POWERS TAYLOR Securities Litigation - Join An Action',

    background:'#FFA500',

    fontColor:'#FFFFFF',

    type:1,

    height:500,

    width:700,

    iframeParameters: {

        'referrer': 'John',

        'referrer2': 'Smith'

    }

    });

    </script>

    <a class="lightbox-30591066142953" style="cursor:pointer;color:blue;text-decoration:underline;">POWERS TAYLOR Securities Litigation - Join An Action</a>

     

    Ultimately I only need to populate the "referrer" field, but its hidden, so I've created the referrer2 field to test. I can't get either one populated when clicking my link. You can see it not working here at the bottom of the content: http://powerstaylor.com/metropolitan-health-networks/

  • Elton JotForm Support
    Answered on March 01, 2013 08:27 AM

    @tpclickz

    Removing the "2" after feedback on the first line of code should fixed it. 

    Example:

    From:

    <script src="//cdn.jotfor.ms/min/g=feedback2" type="text/javascript">

    To:

    <script src="//cdn.jotfor.ms/min/g=feedback" type="text/javascript">

    Thanks!

  • tpclickz
    Answered on March 01, 2013 01:45 PM

    Thanks that did the trick. Not sure why the generated code had the "2" in there, but its working now.