Prefill form with embedded script

  • Profile Image
    bobbymohan
    Asked on October 25, 2011 at 07:45 PM

    Hi,

    I'm using the same form on different brand webpages and I would like to prefill some fields depending on the webpage.

    I'm inserting this code in my pages:

    <script type="text/javascript" src="//form.jotform.com/jsform/XXXXXXXXXX"></script>

    For instance I have a field called 'brand'. I'ld like to prefill that field with the brand name of the webpage.

    I know that you can use prefill if you add for instance ?brand=MyBrand to the contact page url. But I don't want to add a list of parameters in the url. I would rather do something like:

    <script type="text/javascript" src="//form.jotform.com/jsform/XXXXXXXXXX?brand=MyBrand"></script>

    I tried but it doesn't work. This would be transparent to the user (no ugly contact page url) and easy to setup.

    I could also use the source code and add custom values on the fields but it won't update all my forms if I change or add a field.

    Anyone has a solution to prefill using the embedded code?

    Thanks,

  • Profile Image
    fxr
    Answered on October 25, 2011 at 08:01 PM

    The parameters can still be passed with the script embed code.

     

    e.g

    Code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <body>

    <script type="text/javascript" src="//form.jotform.com/jsform//12710415239?brand=honda&model=z1000"></script>

    </body>

     

    Result:

     

    http://pamppi.info/jotform-testing/prefill.html

    ----

    You must have overlooked something in your configuration. Please double check it. 

  • Profile Image
    bobbymohan
    Answered on October 25, 2011 at 09:56 PM

    Hi fxr,

    If you take your script code and use only

    <script type="text/javascript" src="//form.jotform.com/jsform/12710415239"></script>

    it also prefill brand and model, so I think you've set these values as Default Values in the form creator.

    Please le me know if you didn't.

    Thanks.

  • Profile Image
    fxr
    Answered on October 26, 2011 at 04:22 AM

    nope. 

     

    I didnt. I didnt add any default values. The 'blank' form is here -> http://form.jotform.com/form/12710415239

     

    I have changed the prefill values to

    <script type="text/javascript" src="//www.jotform.com/jsform/12710415239?brand=nissan&model=micra"></script>

    result: http://pamppi.info/jotform-testing/prefill.html

     

    NOTE: I did notice a synch issue with the form.jotform.com address, please use www.jotform.com/form/xxxx in your script embed code. This may well have been the source of your problem.

     

     

     

     

     

  • Profile Image
    bobbymohan
    Answered on October 26, 2011 at 06:23 PM

    Hi fxr,

    It's now working!!! I've use: <script type="text/javascript" src="//www.jotform.com/jsform/XXXXXXXX?brand=XXXXX"></script>

    So I've changed http://form.jotform.com/jsform/ to http://www.jotform.com/jsform/

    NOTE: http://form.jotform.com/form/ is not displaying any form (just referring to please use www.jotform.com/form/xxxx )

     

    Thanks for your help,