You are viewing limited content. For full access, please sign in.

Question

Question

How to display a custom html on a form based on specified dropdown selection

asked on March 17, 2022 Show version history

I have a form process where i need to display a msg if certain drop down values are being selected. Below is how i designed it but not working as expected.

I have a dropdown field SSchool_Sel2 and assigned the values to those dropdowns which when selected will display the msg "Maximum selection count reached"

I need some suggestions on how i can achieve this either on the form level based on the field rules or via jscript.

When the user logins to the form based on their id the fields are auto populated based on a lookup rule. When the SSchool_Sel2 dropdown field is clicked the user is given the choices of selecting certain courses. For the 3 courses listed in the dropdown value (above screen shot) the display msg should be visible. If the user selects a course not listed in the above screen shot the display msg should be hidden.

I have the html field hidden in the CSS section of the javascript.

I tried using field rules to show the html msg if the 3 drop down values are selected (as shown in the screen shot) It's not working as expected.

Thanks for your input!

 

0 0

Replies

replied on March 17, 2022

You could show/hide objects with your own script but that is what field rules are there for. I mean your field rule configuration is correct, so this is less of a question and more of a system issue. If you say to show a message when any of the following is true, and it doesn't show when one of those statements is true, something is wrong.

I would contact your VAR to have them look at it as a potential issue.

1 0
replied on March 17, 2022

The only other reason i could think of (maybe am still not sure) is, i assign the drop down values for which the message should show during the field creation on the form. 

But when the form loads after the user login happens, the fields auto populate based on field rule, the sp extracts the values for the dropdown based on the id.

The values could be some of them i've already assigned to the dropdown during the field creation plus few more based on the sp.

But the idea is for the html msg to showup when the assigned values are selected by the user. I hope am explaining myself clearly.

One reason it's not working i could think of is,  since the field values are assigned based on the sp, but i also have the values assigned to the dropdown . Maybe it's overlapping?

 

0 0
replied on March 17, 2022 Show version history

I think @████████ is right that the field rules should be able to hide/show the custom HTML element without issue.  I've done it a lot.

Based on what you've said, I can think of a couple possible issues:

  1. You said "I have the html field hidden in the CSS section of the javascript."  If you have CSS code that is hiding the field, then Field Rules are not going to be able to unhide it.  You're effectively hiding it twice (with CSS and with Field rules) or hiding it once (with CSS).
  2. Also, it sounds like you might be changing some field values from Javascript (I could have misunderstood).  If that is the case, you often have to include code in the Javascript for it to trigger the change event.  Instead of this:
    $('.myClass input').val('new text');
    Something like this:
    $('.myClass input').val('new text').trigger('change');

 

0 0
replied on March 17, 2022

I see your point. 

I commented out the display none on #q38 (which is the html field). I tested it and it still does not show the msg for the dropdowns which is marked in the field rule to show the html msg.

 

I am not changing any field values via js. The field values get populated from a stored proc through a lookup rule. It's coming from a table.

0 0
replied on March 17, 2022

I’m not at a computer to test, but unless I’m mistaken, // does not mean comment in CSS the way it does in Javascript.  Comments in CSS are via /* to start and then */ to end.

1 0
replied on March 17, 2022

This is the field rule

0 0
replied on March 17, 2022

Yes you are right. When i used /* to comment it works.

So now if i comment out #q38 the msg shows as default when the form loads. It should not show unless the drop down selection is made. Any suggestions?

0 0
replied on March 18, 2022

In your "onloadlookupfinished" handler trigger a change event of the source field so that the form can react to the lookup value.  For instance, here's something I've used...

$(document).on("onloadlookupfinished", function(event) {
  $('#Field63-0').change(); // force sense of state of "Update Categories" checkbox to hide tab
  $('#Field64-0').change(); // force sense of state of "Update Programs" checkbox to hide tab
});

 

1 0
replied on March 18, 2022

Let me give this a try. Thanks!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.