Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
190
How do I clear/remove all items from WebDropDown client-side?
posted

Can I see a code sample to remove all WDD items via client-side javascript?

Thanks.

Parents
  • 15979
    Suggested Answer
    posted

    Hello johnvrsm,

    The code that you can use to clear items on Client-Side is shown below:

    <ig:WebDropDown ID="WebDropDown2" runat="server" Width="200px">

       <Items>

             <ig:DropDownItem Selected="False" Text="Item0" Value="0">

             </ig:DropDownItem>

             <ig:DropDownItem Selected="False" Text="Item1" Value="1">

             </ig:DropDownItem>

             <ig:DropDownItem Selected="False" Text="Item2" Value="2">

             </ig:DropDownItem>

       </Items>

    </ig:WebDropDown>

    <input id="Button2" type="button" value="Clear Items" onclick="clearDDItems()" />

     

    <script type="text/javascript">

     

    function clearDDItems() {

     

        var dropdown = $find("WebDropDown2");

     

               

        dropdown._elements["List"].innerHTML = '';

     

     

        dropdown.set_currentValue("", true);                        

    }

       

    </script>

     

    This code will clear the items from the dropdown but since this is a Server control to remove items entirely you will have to clear items from Server collection also.

Reply Children
No Data