locked
Reset drop down menu values RRS feed

  • Question

  • Hello,

    I am using SharePoint 2007 Enterprise Edition.

    I have a number of drop down menus configured to filter a set of search results.

    I want to allow users to press a button marked Clear to remove the filter options they have selected and reset each drop down to All.

    I have decided to use a script to do this that is acvtivated when the user clicks the Clear button. But it is not working, I am using the following script:

    <script type="text/javascript">

         function ApplyClear(event)

         {                

        $("select[DropDownName]").val("All");
      

         }


    </script>

    With no joy. Can any one point me in the right direction with this?

     

    Thanks in advance.

    Monday, December 19, 2011 4:46 PM

Answers

  • Hi EmmaCat,

    If you want reset the all dropdownlist , you can iterate your all dropdownlist on your page, then reset it’s selectindex attribute.

    You can refer to the following jQuery code.

     

     

      $(document).ready(function() {

                $('#myButton').click(function() {

                $("select").each(function() {    

                    //do something here

                        $(this)[0].selectedIndex = 0;

                    });

                });

            });

     

     

    Thanks,

    Jack

    • Marked as answer by Shimin Huang Thursday, December 29, 2011 8:03 AM
    Tuesday, December 20, 2011 9:20 AM
    Moderator