I have a dropdown list as below.
I add an onchnage attribute in my codebehind to call some Javascript.
I want to get the selected text from my dropdown. What am I doing wrong below?
<asp:DropDownLi st ID="ddlStatus" runat="server" />
In my codebehind
ddlStatus.Attri butes["onchange"] = "javascript:Set DateFields();";
<script language="javas cript" type="text/javascript">
function SetDateFields()
{
var statusList = document.getEle mentById("ddlSt atus");
var selectedStatus = statusList.opti ons[statusList.sele ctedIndex].value;
}
</script>
I add an onchnage attribute in my codebehind to call some Javascript.
I want to get the selected text from my dropdown. What am I doing wrong below?
<asp:DropDownLi st ID="ddlStatus" runat="server" />
In my codebehind
ddlStatus.Attri butes["onchange"] = "javascript:Set DateFields();";
<script language="javas cript" type="text/javascript">
function SetDateFields()
{
var statusList = document.getEle mentById("ddlSt atus");
var selectedStatus = statusList.opti ons[statusList.sele ctedIndex].value;
}
</script>
Comment