Prepopulate Fields From Page Content

  • woodlandrlh
    Asked on March 17, 2016 at 4:16 PM

    I've been searching for a few days to this answer and I've gotten close but no cigar. I'm trying to get some of the copy from the page my jotform is embedded on, via wordpress, into some hidden fields. I've tried this:

    var comm = $('#element-51 h1').text();

    $('#input_3').val(comm);

    but I don't really know what I'm doing. Heck, I don't even know if what I want is possible. Any information would be very much appreciated.

    - Jason

     

  • jonathan
    Replied on March 17, 2016 at 4:55 PM

    Hi Jason,

    You did not mention where you are getting the values that you want to use to prepopulate the form. Are using POST data method?

    If it is you will have to use a server-side programming (i.e PHP) to create the page that will populate the fields on the embedded form on the website.

    user guide: PHP-Forms-Explained

    You can also review this similar discussion thread

    https://www.jotform.com/answers/357275-Is-it-possible-to-automatically-grab-Wordpress-user-details-and-add-them-to-form

    OR

    There is a more simpler method. That is by using the page URL with paramater values to populate fields in the embedded form on the website.

    Try this URL on your browser: 

    http://woodlandcapital.org/georgia-land-for-sale/?firstName=jonathan&lastName=jotform

    the result should be like this

    Prepopulate Fields From Page Content Image 1 Screenshot 20

     

    user guide: Prepopulating-fields-to-your-JotForm-via-URL-parameters

    Hope this help. Let us know if you need further assistance.

     

     

     

     

     

  • woodlandrlh
    Replied on March 17, 2016 at 5:02 PM

    Firstly, thanks for taking the time to answer my question; and so quickly!

    Sorry but I should have been more implicit in my description. I would like to get the values from some of the page elements into the form. My example script was attempting to put the text "1 to 150 Acres Available" into the First Name field, as a test.

    I'm already updating my hidden fields via the URL, utm tracking stuff, but I don't want to have each of the links in my site stuffed with variables. (The link I sent is just a test landing page not the full site)

    I found something of answer in this forum that lead to this jsfiddle http://jsfiddle.net/L4mWh/4/  but I can't make heads or tails of what's going on.

  • jonathan
    Replied on March 17, 2016 at 5:43 PM

    If I am not mistaken you were referring to this thread  http://www.jotform.com/answers/343411

    You will probably have to use your form source code to embed  on your website because you will need to inject jquery functions to it.

    In the example jsfiddle, you can see the javascript code that creates the population function. You will need to add this javascript in your website page along with the form source code.

    The 'text' value you were trying to use in your test to popuate the First Name field has an input ID as 'element-2'

    Prepopulate Fields From Page Content Image 1 Screenshot 20

     

     

    will you be able to use source code embed of the form on your WP page? This might be an essential requirement for the whole function to work.

    I suggest you test it first by creating a test page in your WP site then embed the source code of the form to that test page. You can then add the javascript on the test page and test the function code.

    Let us know how we can be of further assistance.

    Regards