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

    Triggering Conditions

    Asked by listingtoolbox on January 24, 2013 at 10:09 PM

    Hi there,

    We have used JotForm source code and incorporated into our own .Net based application.  Our plan is to save submitted data into our own DB.

    We have a requirement for users to be able to come back and continue filling in a partially completed form.  (A very long form that uses conditions to expose different sections based on answers to key questions).

     

    When we populate the form with our own data that the user filled in during a previous session, none of the Show/Hide conditions work.  Per other forum Q&As the triggering of Show/Hide conditions appears to be based on the user/mouse selecting them.  Is there any way to programmatically trigger a given condition after re-populating a field with our data?

    Here's a very early prototype:

    http://ltbprototype.apphb.com/

    You can quickly register for an account (top right) and once you log in click on the Forms tab.  There are a couple of fields where we're populating data to simulate a user coming back.  The Province field starts with 'British Columbia' selected but if you un-select and select again you'll see the proper behaviour we'd like to elicit (two more fields below appearing).

    Alternatively do you have any suggestions for using other strategies for form design that would allow the show/hide of large sections of forms while still allowing us to save data to a custom DB, allow users to come back to partially work on a partially completed form and have the show/hide conditions work when the data is re-populated?

    Thanks for any thoughts.  So far finding it great and easy to use the JotForm environment to have non-technical people generate the forms.  Just hope we can find a way to incorporate into our system.

    Dennis

  • Profile Image
    JotForm Support

    Answered by idarktech on January 24, 2013 at 11:59 PM

    Hi Dennis,

    Try modifying your form source code, make the British a selected value on your drop down by adding selected="selected" attribute. Example:

    And for the other fields, like check boxes and radio buttons, use URL paratmers for prepopulating fields to trigger the conditions. Example:

    http://ltbprototype.apphb.com/Form?aNew=Coming%20from%20Other%20Mere%20Post%20Provider

    aNew is the name of the Listing Request field

    Coming%20from%20Other%20Mere%20Post%20Provider is one of its value. "Coming from Other Mere Post Provider"

    Here's a more detailed guide on how to prepopulate values to the form fields. Prepopulating the fields to your JotForm via URL parameters

    Let us know if you have further questions. Thanks

  • Profile Image
    JotForm Support

    Answered by idarktech on January 25, 2013 at 12:02 AM

    Alternatively do you have any suggestions for using other strategies for form design that would allow the show/hide of large sections of forms while still allowing us to save data to a custom DB, allow users to come back to partially work on a partially completed form and have the show/hide conditions work when the data is re-populated?

    Try using Form Collapse tool. Check this guide: How to Hide or Show Multiple Fields at Once Based On a Single Conditional Entry.

    Thanks!

  • Profile Image

    Answered by listingtoolbox on January 25, 2013 at 02:25 AM

    Hi there,

    Thanks for your quick response. I tried your sugguest to toggle the selected attribute on the option elements, but the change event / trigger for the condition still not firing up. I even tried to manually invoke the event ($(selectlist).change()), but still no luck. Any ideas?

    Bob 

  • Profile Image
    JotForm Support

    Answered by idarktech on January 25, 2013 at 04:32 AM

    Hi Bob,

    I have tried it using window.onload function. Try using the following code, just add it after the end tag </form> of your form source code.

    <script type="text/javascript">

    (function () {

        window.onload = function () {

            if ($F("input_1") === "British Columbia") {

                $("id_2").style.display = "block";

        $("id_200").style.display = "block";

            }

        };

    })();

    </script>

    After that prepopulate data using URL parameters. Example:

    http://ltbprototype.apphb.com/Form?province=British%20Columbia

    Try creating the other codes for the other conditions out of that idea. I think that would help.

    Thanks!

  • Profile Image

    Answered by listingtoolbox on January 25, 2013 at 06:55 PM
    Hi there, Ideally, we don't want to hard code any logic about field / form conditions in our code. When we programmatically change the value of a select list element that has jotform condition, how come jotform javascript code did not get executed to hide or show certain fields. Thanks Bob
  • Profile Image
    JotForm Support

    Answered by idarktech on January 25, 2013 at 11:35 PM

    Sorry about that. I agree, my suggestion would be a bit laborious. Unfortunately that's the only way I could think of. By the way, I have tried adding selected="selected" attribute on the "British Columbia" and it seems to be working fine. Check this test http://idarktech.com/test/test_169483.html

    Let me also forward this to our development team so they can further investigate the issue. Thanks!

  • Profile Image
    JotForm Support

    Answered by abajan on January 26, 2013 at 04:18 AM

    @listingtoolbox

    For what it's worth, if you don't wish to edit the form's source, you could programatically select British Columbia as illustrated in this demo (see the script at the bottom of the page's source).

    Incidentally, I tried the less verbose
    $("input_1").down(2).writeAttribute("selected", "selected");
    and it triggered the conditions as expected but for some reason the dropdown had to be clicked to show British Columbia.

  • Profile Image

    Answered by listingtoolbox on January 27, 2013 at 02:44 PM

    Hi abajan,

    Thank you for your reply. We are actually updating form fields in a ajax callback, that is on page load, we make a ajax call to fetch form data from our server and then populate value to corresponding fields. I tried your call in the call back, it did not work. But when I put it outside the callback and hard-code the element id and value, it worked. Any idea?

    Thanks

  • Profile Image
    JotForm Support

    Answered by jonathan on January 27, 2013 at 05:13 PM

    @listingtoolbox

    Hi, perhaps what was discussed on this thread could also help. In my understanding, it is all about validation and passing values (which you can also use POST method).

    You may want to give it a review until my colleagues abajan or idarkteck are back online again to give you update on your discussions.

    Thanks.

  • Profile Image

    Answered by listingtoolbox on January 31, 2013 at 11:04 PM

    Hi abajan & idarkteck,

    Any further ideas from my post on Jan 27th?

    Thanks.

  • Profile Image
    JotForm Support

    Answered by EltonCris on February 01, 2013 at 03:19 AM

    @listingtoolbox 

    Sorry to say but we haven't heard any updates from our dev team about this report yet. It may take a while before this can be corrected due to the workloads assigned to them. In the meantime, have you tried the previous suggestions from my colleague abajan? Perhaps, the one that you got it to work would be the best solution for now.

    My apologies.

  • Profile Image
    JotForm Support

    Answered by EltonCris on February 04, 2013 at 09:53 AM

    @listingtoolbox,

    Our dev team have just implemented a fix for this. We would suggest to clear your browser's cache first before making a test.

    Thanks!

    Here's an example: http://www.jotformpro.com/form/30248773639968?fruit=Apple (text area should appear when fruit = apple)