G
Guest
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?
<aspropDownList ID="ddlStatus" runat="server" />
In my codebehind
ddlStatus.Attributes["onchange"] = "javascript:SetDateFields();";
<script language="javascript" type="text/javascript">
function SetDateFields()
{
var statusList = document.getElementById("ddlStatus");
var selectedStatus = statusList.options[statusList.selectedIndex].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?
<aspropDownList ID="ddlStatus" runat="server" />
In my codebehind
ddlStatus.Attributes["onchange"] = "javascript:SetDateFields();";
<script language="javascript" type="text/javascript">
function SetDateFields()
{
var statusList = document.getElementById("ddlStatus");
var selectedStatus = statusList.options[statusList.selectedIndex].value;
}
</script>