Form with Drop Down; Selection not showing

KWiggKWigg SLC, UTCommunity Member Qubie ✭

Form with Drop Down; Selection not showing

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:


Best Answer

  • rondevrondev Community Member - Trial User Wizard ✭✭✭✭✭
    edited June 2020 Accepted Answer

    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.

Answers

  • KWiggKWigg SLC, UTCommunity Member Qubie ✭

    @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!

  • rondevrondev Community Member - Trial User Wizard ✭✭✭✭✭

    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);
    
Sign In to Comment