While using javascript and asp.net, I have encountered an issue with the AutoPostBack function clearing a variable called 'callBackReason' that I declared in Javascript from a dropdownlist. Unfortunately, I need to keep this variable in Javascript even after the AutoPostBack occurs. Is there a way to achieve this?
Thank you in advance.
<asp:DropDownList AutoPostBack="true" OnSelectedIndexChanged="dropVehicleRequest_Changed" runat="server" ID="dropVehicleRequest"></asp:DropDownList>
<asp:DropDownList runat="server" ID="dropCallbackReason" SelectedIndexChanged="riskSeverityDropDown_SelectedIndexChanged" onChange="javascript:updateCallBackReason()" ClientIDMode="Static" >
<asp:ListItem Text="-- Select Reason --" Value="1"></asp:ListItem>
<asp:ListItem Text="Booking" Value="2"></asp:ListItem>
<asp:ListItem Text="Discussing" Value="3"></asp:ListItem>
<asp:ListItem Text="Contact" Value="4"></asp:ListItem>
</asp:DropDownList>
<script type="text/javascript">
function updateCallBackReason() {
callBackReason = document.getElementById('<%=dropCallbackReason.ClientID%>').options[document.getElementById('<%=dropCallbackReason.ClientID%>').selectedIndex].text;
return callBackReason;
}
</script>