multi select dropdown search code example

Example 1: asp multi select dropdown

<asp:ListBox runat="server" SelectionMode="Multiple" >
  <asp:ListItem Text="test1"></asp:ListItem>
  <asp:ListItem Text="test2"></asp:ListItem>
  <asp:ListItem Text="test3"></asp:ListItem>
</asp:ListBox>

Example 2: multiselect dropdown with checkbox typescript

onChange(index_val) {
    this.zoneModel = []
    if (index_val == 0 && this.zonesList[0].checked == true) {
      for (let i = 1; i < this.zonesList.length; i++) {
        this.zoneModel.push(this.zonesList[i].houzeyZoneName)
        this.zonesList[i].checked = true;
        this.zoneFlag = true;
      }
    } else if (index_val == 0 && this.zonesList[0].checked == false) {
      for (let i = 1; i < this.zonesList.length; i++) {
        this.zonesList[i].checked = false;
        this.zoneFlag = false;//testing
      }

    } else if (index_val > 0) {

      for (let i = 1; i < this.zonesList.length; i++) {
        if (this.zonesList[i].checked == true) {
          this.zonesList[i].checked = true;
          this.zoneFlag = true;
          this.zoneModel.push(this.zonesList[i].houzeyZoneName)
          if (this.zoneModel.length == this.zonesList.length - 1) {
            this.zonesList[0].checked = true;
          }
        } else {
          //this.zoneFlag = false;//testing
          this.zonesList[i].checked = false;
          if (this.zonesList[0].checked == true) {
            this.zonesList[0].checked = false;
          }

        }
      }
    }



  }