Values in pre-populated fields aren't showing conditions

  • Profile Image
    semory
    Asked on January 09, 2013 at 01:31 PM

    I have fields values on my homepage that are transfered over to a larger form on a different page after the user submits. One of the fields triggers conditions depending on whats selected. But the conditions don't work if the inputs are prepopulated. Is there any thing I can do. Hoping I don't have to resort to using the source code. Any help would be greatly appreciated.

  • Profile Image
    abajan
    Answered on January 09, 2013 at 01:42 PM

    Hi,

    Unfortunately, I'm pretty sure you would have to resort to using the source code for the second form: Something along the lines of calling a function the triggers the conditions when the page is loaded:

    window.onload = nameOfFunctionWhoseContentTriggersConditions;

    or perhaps

    window.onload = function () {
    codeThatTriggersConditions;
    };

    but I'll have a look at your setup and see if there's an alternative way. My colleagues may also have better solutions.

  • Profile Image
    Welvin
    Answered on January 09, 2013 at 02:04 PM

    @semory,

    Have you recently replied to this thread? Can you please visit this thread and repost it again.

    http://www.jotform.com/answers/164352-Values-in-pre-populated-fields-aren-t-showing-conditions

    Thanks

  • Profile Image
    semory
    Answered on January 09, 2013 at 02:22 PM

    @Welvin - no I haven't replied since my original question. I am hoping there is a solution that doesn't involve the need to use source code. Waiting to see if abajan finds out anything else.

  • Profile Image
    semory
    Answered on January 09, 2013 at 02:50 PM

    Trying to come up with a hack. Would showing a hidden field containing a value trigger a condition?

  • Profile Image
    idarktech
    Answered on January 09, 2013 at 04:35 PM

     

    @semory

    There seems to be a conflict between the form and the your site scripts because the form validation doesn't work. Therefore, conditions may not work as well since they need its script to be able to run properly. This could possibly be the reason why prepopulation is not working but I'm not quite really sure about that.

    Also, any reason why the form script <!--<script src="//max.jotfor.ms/min/g=jotform?3.1.1316" type="text/javascript"></script>0--> is marked as comment? This is needed for the form condition and validation to work.

    Thanks.

     

  • Profile Image
    semory
    Answered on January 09, 2013 at 06:39 PM

    Hi idarktech,

    I've been trying different things so the form might not have been working when you looked at it. On the homepage I commented out (temporarily) the link to the .js because of the prototype/jquery conflict.

    The prepopulation is working great. The problem is that the fields that have dynamic values from the homepage don't trigger their conditions. The state pulldown is supposed to generate different questions below depending.

    Are there any possible workarounds besides source? 

    Seems like this would be very easy to implement in the core js file. Any chance?

  • Profile Image
    idarktech
    Answered on January 09, 2013 at 07:14 PM

    @semory

    Thanks for your swift reply.

    Unfortunately there's no possible workaround without touching the code. Also, you are already using your form's source code and had applied some custom scripts. Is this the workaround that you'd like to replace without touching the source?

    Another thing is, your form's stand alone version doesn't have any working conditions (all are deleted), therefore no conditions will be triggered when fields are prepopulated. Are these conditions custom made?

    Moreover, the form on some of your page which you are referring to isn't from JotForm http://truckerschools.com/find-a-school/wyoming/? (form on your homepage doesn't have dropdown state field so I am thinking you are talking about this form). Unfortunately, there's nothing we can do about non-JotForm forms.

    Thanks!

  • Profile Image
    idarktech
    Answered on January 09, 2013 at 07:25 PM

    Nevermind, I think I've found the form here: http://truckerschools.com/apply-now/.

    We'll check it further. Thanks!

  • Profile Image
    semory
    Answered on January 09, 2013 at 07:34 PM

    Hi idarktech,

    Thanks for the help. At this point I think I am going to drop the conditions if they can't be triggered when prepopulated. No big deal. I don't want to use source because the css is getting messed up because of conflicts with my existing stylesheet. On the smaller form on the homepage it doesn't seem to be as big of a deal.

     

    This would be a nice feature to have in the future without having to use source.

    Thanks

  • Profile Image
    abajan
    Answered on January 09, 2013 at 07:48 PM

    @semory

    Prepopulation definitely will not trigger conditions, as illustrated in this small demo form that has a condition to show a text area only if the word yes is entered in the text box. It works fine if you manually enter the word but if you were to click the following prepopulating link, the text area won't be shown even though the text box contains yes:

    http://www.jotformpro.com/form/30087216252952?addComments=yes

    I'm going to try to find a workaround but it will require using the full source. (If CSS conflicts is the only reason for your not using the full source, I'm sure we can help you sort that out.)

  • Profile Image
    semory
    Answered on January 09, 2013 at 09:16 PM

    I decided to go with using the source. I tried to do a window.onload on the conditions and I am now getting an error on the jotform js. This is the code I have:

    <script type="text/javascript">

    window.onload = function () {

       JotForm.setConditions([{"type":"field","link":"Any","terms":[{"field":"25","operator":"equals","value":"Texas"}],"action":[{"field":"15","visibility":"Show"}]},{"type":"field","link":"Any","terms":[{"field":"25","operator":"equals","value":"District of Columbia"},{"field":"25","operator":"equals","value":"Maryland"},{"field":"25","operator":"equals","value":"Delaware"},{"field":"25","operator":"equals","value":"New Jersey"},{"field":"25","operator":"equals","value":"Pennsylvania"}],"action":[{"field":"16","visibility":"Show"}]},{"type":"field","link":"Any","terms":[{"field":"25","operator":"equals","value":"Illinois"}],"action":[{"field":"17","visibility":"Show"},{"field":"18","visibility":"Show"}]},{"type":"field","link":"Any","terms":[{"field":"25","operator":"equals","value":"Maryland"}],"action":[{"field":"19","visibility":"Show"},{"field":"20","visibility":"Show"},{"field":"9","visibility":"Hide"}]}]);

       };

     

    Any help would be greatly appreciated.

  • Profile Image
    semory
    Answered on January 09, 2013 at 09:17 PM

    I have the closing </script> fyi.

  • Profile Image
    abajan
    Answered on January 09, 2013 at 09:54 PM

    Hi again,

    Firing conditions via a query string is possible. Here's the same demo form embedded in a web page. Now, if the following prepopulating link is clicked, the textarea is shown:

    http://formdemos.awardspace.biz/form_30087216252952.html?addComments=yes

    The only difference is that my onload validation is stricter: It must be exactly yes (no more, no less) while the JotForm validation allows any string containing yes ("yesindeed", "jhkjhnyesfvf" and "the answer is yes" would all work).

    Anyway, I'll see how best I can apply the solution to your form tomorrow.

  • Profile Image
    abajan
    Answered on January 09, 2013 at 10:02 PM

    Hi Shawn,

    I got the submission you just made. I've just put an autoreponder in the form so that you can see how it looks if you do another submission.


    Wayne

  • Profile Image
    semory
    Answered on January 09, 2013 at 10:08 PM

    Thanks so much!!! I was able to take your code and apply it to my site. JotForm definitely has the best support around.

  • Profile Image
    jeanettebmz
    Answered on January 09, 2013 at 10:47 PM

    I am very happy to see our brilliant Wayne (Abajan) sorted out your request! Thank you very much for your awesome feedback toward us!

    Cheers!

  • Profile Image
    abajan
    Answered on January 10, 2013 at 09:04 PM

    Hi Shawn,

    I'm pleased to hear you got the solution to work. And your compliment is much appreciated.

    Just a couple things I noticed when testing the form on the page to which users are redirected upon completing your first form:

    1. Missouri hides the id_9 field via the query string but not if it's manually selected

    2. Less important but still worth noting is that in your script a switch statement can be substituted for the multiple if statements. (It's mostly just a matter of preference though)

    In relation to the first point, both the injected CSS and script can be edited to prevent users from changing their prepopulated entries, thereby eliminating the Missouri issue.

    This demo contains the above changes.

    If you would like further assistance with your forms, we'd be happy to help.


    Wayne