Amit

Amit

  • 1.1k
  • 213
  • 34.3k

Asp.net Multiselect DDL onchange event

Feb 23 2024 12:07 AM

Multiselect ddl and textbox.

1)whenever i am selecting ddl item and put email in text box for each item manually . i want to add ',' before second email id put in text box. 

2) if i am unselecting perticular item form ddl that time regarding textbox email is remove from textbox.

3) i have Email3 and Email4 hardcoded text.

<select id="ddltext" runat="server" data-placeholder="--Select--" multiple class="selectpicker"  onchange="GetSelectedValue();">
                                                <option></option>
                                                                                            
                                                 <option>Email1</option>
                                                <option>Email2</option>
                                                <option>Email3</option>
                                                <option>Email4</option>   

                                                <option>Email5</option>                                                                                             
        <asp:TextBox ID="txtEmailId" runat="server" CssClass="form-control"></asp:TextBox>    

function GetSelectedValue() {
    debugger;
    
    var SelectedITem = $(".selectpicker option:selected").text();
   // var strUser = SelectedITem.options[SelectedITem.selectedIndex].text();  
    if (SelectedITem == 'Email3' || SelectedITem == 'Email4') {       
           txtEmailID.value = "[email protected]";
       }
       else {
         txtEmailID.value = "";
        }
}


Answers (1)