PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Conditional logic not quite working

  1. beclo
    Member

    I've got a form with some conditional fields. The conditions are set by JavaScript (jQuery) modifying the value of a hidden field. e.g. I do:

    jQuery('#input_1_24').attr('value', 'yes');

    However, setting this value doesn't seem to trigger the conditions being updated.

    Is there some JavaScript event that I need to fire, or function I need to call to get the conditions to be re-evaluated?

    Posted 12 years ago on Friday November 23, 2012 | Permalink
  2. beclo
    Member

    In case you're wondering I've used jQuery('#input_1_24').val('yes').change() and that doesn't seem to re-evaluate the conditions.

    Posted 12 years ago on Friday November 23, 2012 | Permalink
  3. beclo
    Member

    Form is at: http://order.sendmyfriend.org

    I'm trying to get fields 21 and 22 to appear when function smf_crafty_show_address() is called (it's called as a callback by another script)

    You can test this by entering the postcode AA11AA, clicking the "Find Address" button and then selecting an address. The callback is called when you select an address from the dropdown.

    Thanks

    Posted 12 years ago on Friday November 23, 2012 | Permalink
  4. I'll bring this to the attention of the development team. As far as I know, the conditional logic rules are present when the form is rendered. Take a look at the source of the page and you can see them. If you change a value on the form after it is rendered, I think you would have to update the rules as well, or the conditional logic would not work.

    Posted 12 years ago on Monday November 26, 2012 | Permalink
  5. The problem is that hidden fields are not programmed to update the conditional logic in the client side via javascript. What I recommend you do is use a regular text field instead of the hidden field and add "gform_hidden" in the CSS Class Name field setting. That css class will hide the field, but you will still be able to trigger your conditional logic via javascript. I think you will need to use the .change() at the end of your statement (like your second attempt), but you may not need to.

    Posted 12 years ago on Monday November 26, 2012 | Permalink