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 customize an input value when the form is in lightbox?

    Asked by jacopogalli on May 09, 2011 at 09:02 AM

    Hi to all, 

    I know how to pass a "dynamic" value to set an input field when the form is creating (URL GET params whith for example ?user_id=$php_var_user_id).

     

    But, what about if the form opens in lightbox? Something to set in your javascript code!?

     

    Thanks

    Jacopo

  • Profile Image
    JotForm Support

    Answered by liyam on May 09, 2011 at 11:28 AM

    Hello Jacopo,

    Yes, this is still possible but you will need to create a javascript that will accept URL parameters and assign javascript variables to the lightbox script.

    You need add the property iframeParameters in your script.

    example:

    <script src="//www.jotform.com/min/g=feedback" type="text/javascript">
    new JotformFeedback({
    formId:'10563005897',
    base:'http://www.jotform.com/',
    iframeParameters: {
         'yourName15[first]': 'John',
         'yourName15[last]': 'Smith'
    },

    windowTitle:'test',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:500,
    width:700
    });
    </script>

    On the above example, yourName15[first] & yourName15[last] are the field names in my form sample. The value beside it are values. If you wish for it to become a variable you will just need to remove the quotes (').

    example:
         'yourName15[first]':fname_param,
         'yourName15[last]':lname_param
     
     

    Posting URL parameters via javascript:

    Paste this script in your HTML file (anywhere as long as it is above your jotform feedback script):

    <script type="text/javascript">
    function getURLparameter( name )
    {
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href );
      if( results == null )
        return "";
      else
        return results[1];
    }
    </script>

    Now let's go back to the jotform feedback script source.  You will need to declare your variable with the function in it.

    example:

    var fname_param = getURLparameter( 'yourName15[first]' );
    var lname_param = getURLparameter( 'yourName15[last]' );

     

    Place the variable declarations above of the jotform feedback script.

    example:

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

    var fname_param = gup( 'yourName15[first]' );
    var lname_param = gup( 'yourName15[last]' );

    new JotformFeedback({
    formId:'10563005897',
    base:'http://www.jotform.com/',
    iframeParameters: {
         'yourName15[first]':fname_param,
         'yourName15[last]':lname_param
    },
    windowTitle:'test',
    background:'#FFA500',
    fontColor:'#FFFFFF',
    type:false,
    height:500,
    width:700
    });
    </script>

    Now save the file and test it.

    You can also check my sample running script and check the source code.  Feel free to change the parameter values:

    http://ravnos.t35.com/jotform_feedbackURLparams.html?yourName15[first]=John&yourName15[last]=Smith

    If you have other questions and inquiries, please let us know.

    Thanks

  • Profile Image

    Answered by dr770 on December 18, 2011 at 06:01 PM

    Hi liyam,

    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

  • Profile Image
    JotForm Support

    Answered by idarktech on December 19, 2011 at 05:03 PM

    @dr770,

    Thank you for asking. Please use this thread for answer/updates on your question. Thank you so much!

    http://www.jotform.com/answers/63481-dynamic-php-variable-to-lightbox#3