Results 1 to 2 of 2
  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Sitting in an empty room trying to forget the past

    Getting javascript object required error

    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:

    								<tr><!-- This is the row with Effective Date -->
    									<td nowrap valign="top">
    										<asp:label id="EffectiveDateTitleLabel" runat="server" Width="120px">Effective Date:</asp:label>
    									<td nowrap valign="top">
                                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                    <asp:dropdownlist id="EffectiveDateDropDown" runat="server" onchange="SetTextArea(this.value)"></asp:dropdownlist>
                                                    <asp:AsyncPostBackTrigger ControlID="QuoteType" 
                                                        EventName="SelectedIndexChanged" />
    								<tr><!-- This is the row with Total Employees -->
    									<td nowrap valign="top">
    										<asp:label id="TotalEmployeesLabel" runat="server" Width="120px"> Total Employees</asp:label>
    									<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>
    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:
    	<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";
                        alert("Could not find TotalEmployees");
    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.

    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Land Down Under

    Re: Getting javascript object required error

    I think you need to use PageRequestManager for custome JS inside a updatePanel.

    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.