How to use onchange event of DropDownList using Javascript?

By James J

Set onchange event of DropDownList using javascript...

<asp:DropDownList ID="DropDownList1" runat ="server" Width="235px" AutoPostBack="False">
    
<asp:ListItem>Item 1</asp:ListItem>
    
<asp:ListItem>Item 2</asp:ListItem>
    
<asp:ListItem>Item 3</asp:ListItem>
    
<asp:ListItem>Item 4</asp:ListItem>
</asp:DropDownList>

<script type ="text/javascript" >
      function change()
      {
//Set here your logic...
       }
</script>


protected void Page_Load(object sender, EventArgs e)
{
    DropDownList1.
Attributes.Add("onchange", "change();");
}

How to use onchange event of DropDownList using Javascript?  (2919 Views)