I am getting an object required error and I understand it's because the object I am looking for doesn't exist yet, but I don't know why it doesn't exist yet. Here is my code:
Code:
<tr><!-- This is the row with Effective Date -->
<td nowrap valign="top">
<asp:label id="EffectiveDateTitleLabel" runat="server" Width="120px">Effective Date:</asp:label>
<p></p>
</td>
<td nowrap valign="top">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:dropdownlist id="EffectiveDateDropDown" runat="server" onchange="SetTextArea(this.value)"></asp:dropdownlist>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="QuoteType"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr><!-- This is the row with Total Employees -->
<td nowrap valign="top">
<asp:label id="TotalEmployeesLabel" runat="server" Width="120px"> Total Employees</asp:label>
<p></p>
</td>
<td nowrap valign="top">
<asp:DropDownList id="TotalEmployees" runat="server">
<asp:ListItem Value="" Selected="True">No preference</asp:ListItem>
<asp:ListItem Value="1">19 or fewer employees working for the company</asp:ListItem>
<asp:ListItem Value="0">20 or more employees working for the company</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
What I want to accomplish is when the selected effective date is greater than 01/01/2014, hide the TotalEmployees dropdownlist (and label, but for now I'm just trying to do the DDL).
Here's the js:
Code:
<script type="text/javascript">
function SetTextArea(selectedValue) {
alert("selected value changed to " + selectedValue);
var selectedDate = new Date(selectedValue);
var cutoffDate = new Date("01/01/2014");
if (selectedDate > cutoffDate) {
var theObj = document.getElementById("TotalEmployees"); //.style.display = "none";
if(!theObj)
alert("Could not find TotalEmployees");
}
}
</script>
I get the alert that it could not find totalemployees. Is this because EffectiveDateDropDown is in an UpdatePanel so the two dropdowns don't exist at the same time? Or something like that?
I don't have to use JS. I thought it would be easier than using AJAX. But it's not if it doesn't work.
Thanks.