Form with Drop Down; Selection not showing | XM Community
Solved

Form with Drop Down; Selection not showing

  • 19 June 2020
  • 3 replies
  • 259 views

Badge +9

Hey guys, I've been combing through the forums for two days and just can't find a solution to the issue.
I have a form with a drop down option within it. Everything works fine, until the page is left. Whether returning to the page via back button, or even the question appearing in the survey summary, the options selected are gone. Is there a way to keep the selection, once made, and allow for a change if needed?
Below is the code I'm currently using:
image.png

icon

Best answer by rondev 19 June 2020, 21:10

View original

3 replies

Userlevel 7
Badge +22

You need to store the selected option in an embedded data and after inserting the drop down element, check the embedded data, if it is not empty then select that option from the drop down and then put the selected option in input text.
OR
After hiding both the input text, check if they are not empty, then get the text and select the option with same text.

Badge +9

rondev thank you, that's very helpful. I had attempte to use an embedded field previously, but didn't think to add a check in the drop down code. Do you happen to know which type of commands I'll need to use in javascript to accomplish this?
Thanks again!

Userlevel 7
Badge +22

After jQuery("#"+that+" .InputText:eq(1)").hide(); add below lines:
jQuery("#s1 option").filter(function() {
  return jQuery(this).text() ==jQuery("#"+that+" .InputText:eq(2)").val();
}).prop("selected", true);

jQuery("#s2 option").filter(function() {
  return jQuery(this).text() ==jQuery("#"+that+" .InputText:eq(1)").val();
}).prop("selected", true);

Leave a Reply