Using js (jquery) to select only the 1st item in a select component - Forum - Mobile - Progress Community

Using js (jquery) to select only the 1st item in a select component

 Forum

Using js (jquery) to select only the 1st item in a select component

This question is answered

I have a filter page and would like to reset the values back to default whenever they enter or leave (don't care which one) the page. The first item in the select is "Choose..." with a value of "". I added another property to make it allow multiple. So, if they choose multiple options and filter or cancel, I want it to move the selection back to only Choose... (or empty value). I've created the page hide or page show event and tried many different ways, all of which have failed. I have tried casting Progress('selectName').val(0); and Progress('selectName').val(""); and many variants of jquery, like $("select[name='testSelect']:selected").first().attr("selected", false); and others. If I have mutliple on, do I need to use the checked property instead? Do I need to call a refresh somehow (looked and didn't see one)?

Verified Answer
  • Hi Riche,

    please try this code:

    $("[dsid=selectName]").val("Vici").selectmenu("refresh", true);

    Let me know if you have any questions.

All Replies
  • Hello,

    I believe that you need a line of code like the following:

       $("[dsid=selectName]").val("Vici").change();

    I hope this helps.

  • This actually only half works for me. It does make it so that it only shows Choose..., but if they click on it to get the popup of choices, the choices are still checked. I looked at the values of the options in the debugger and they all have the selected property as false and the main control has a selectedindex of -1, but it still has them selected when it opens.

  • Hi Riche,

    please try this code:

    $("[dsid=selectName]").val("Vici").selectmenu("refresh", true);

    Let me know if you have any questions.