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

    Use javascript to change the form displayed?

    Asked by MetalSupport on March 17, 2016 at 11:32 AM

    Hi there,

    I am currently trying to use some Javascript code to dynamically change the form displayed on a page. I first tried it by changing the src attribute on the <script> tag but this wouldn't work as the script would not run again.

    I then tried embedding the form as an Iframe and changing the src attribute with Javascript. This actually worked! However, the form's conditions would not work anymore. The form has a condition where it pulls and URL parameter (city) and runs a few conditions based on that (echo GET['city'];).

    It just seems that the echo GET['url-parameter']; tag does not work when the form is embed as an iFrame. The final result that I am trying to achieve is that if the url parameter city=houston, the form for Houston appears and if city=newyork, the form for NYC appears.

    Would you please provide suggestions on how to address one of the following issues:

    - GET['url'] tag not working in iFrames

    - A simpler way to switch the form that is being embed on the site via Javascript

    Thanks!

    displayed use site does not work thanks then
  • Profile Image
    JotForm Support

    Answered by david on March 17, 2016 at 11:53 AM

    The easiest way to accomplish this would be to have two forms embedded to a main form using iFrame widgets:

    http://www.jotform.com/help/148-Getting-the-Form-iFrame-Code

    The main form would have a selection for "City" and would conditionally show the appropriate city form when the option is selected:

    http://www.jotform.com/help/57-Smart-Forms-Using-Conditional-Logic

  • Profile Image
    JotForm Support

    Answered by david on March 17, 2016 at 11:54 AM

    My apologies, I link the iFrame code, rather than the iFrame widget.  Here is the proper link for the widget:

    http://widgets.jotform.com/widget/iframe_embed