JS Error, need a fresh pair of eyes to look at it

Discussion in 'Javascript' started by Luminousc, Mar 23, 2005.

  1. Luminousc

    Luminousc Guest

    I get the dreaded, 'is null or not an object' at runtime. This happens
    on the:
    " if (SearchAndNavFormID.QuickSrchID.value != "") " line.

    Here's my ascx source:

    <%@ Control Language="c#" AutoEventWireup="false"
    Codebehind="DTS_SearchAndNav.ascx.cs"
    Inherits="DTS_UI.Components.DTS_SearchAndNav"
    TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <script language="javascript">
    function ToggleSelectBox()
    {
    if (SearchAndNavFormID.QuickSrchID.value !=
    ""){SearchAndNavFormID.ViewTypeID.disabled = true;}
    else {SearchAndNavFormID.ViewTypeID.disabled = false;}
    }
    </script>
    <div align="center" style="BORDER-TOP:black 1px solid; MARGIN-TOP:5px;
    MARGIN-BOTTOM:5px; PADDING-BOTTOM:3px; WIDTH:400px; PADDING-TOP:1px;
    BORDER-BOTTOM:black 1px solid;>
    <div id="tommy" align="center" style="filter:alpha(starty=0,
    finishy=100, startx=0, finishx=0, opacity=60, finishopacity=100,
    style=1); WIDTH:400px; BACKGROUND-COLOR:#A0A0D0">
    <form name="SearchAndNavForm" id="SearchAndNavFormID"
    action="DTSList.aspx" method="post" style="margin:0px, padding:0px">
    <small style="FONT-SIZE:9px; Color:#000000">Quick Search
    &nbsp;<input onblur="ToggleSelectBox()" type="text" name="QuickSrch"
    id="QuickSrchID" style="MARGIN-TOP:2px; FONT-SIZE:11px; WIDTH:140px;
    BACKGROUND-COLOR:white"><span style="WIDTH:1px"></span></small>
    <select ID="ViewTypeID" name="ViewType" style="FONT-SIZE:9px;
    WIDTH:106px; BACKGROUND-COLOR:white">
    <option <%if ((Session["gl_ViewType"] as string).ToLower() ==
    "newreqs"){Response.Write("selected");};%> value="NewReqs"
    style="FONT-WEIGHT:800" selected>New Requests</option>
    <option <%if ((Session["gl_ViewType"] as string).ToLower() ==
    "myreqs"){Response.Write("selected");};%> value="MyReqs"
    style="FONT-WEIGHT:800">My Requests</option>
    <option <%if ((Session["gl_ViewType"] as string).ToLower() ==
    "mywishreqs"){Response.Write("selected");};%> value="mywishreqs"
    style="FONT-WEIGHT:800">My Wish List</option>
    <option <%if ((Session["gl_ViewType"] as string).ToLower() ==
    "wishreqs"){Response.Write("selected");};%> value="wishreqs"
    style="FONT-WEIGHT:800">Main Wish List</option>
    <option <%if ((Session["gl_ViewType"] as string).ToLower() ==
    "exreqs"){Response.Write("selected");};%> value="exreqs"
    style="FONT-WEIGHT:800">Other Requests</option>
    </select>
    <input type="submit" value="GO" style="MARGIN-TOP:2px;
    FONT-SIZE:9px; WIDTH:23px; BACKGROUND-COLOR:white" ID="SubmitBtnID"
    NAME="SubmitBtn">
    <br>
    <input type="button" onclick="location.href='DTSSearch.asp'"
    style="MARGIN-TOP:2px; FONT-SIZE:9px; WIDTH:214px;
    BACKGROUND-COLOR:white"
    value="Advanced Request Search"> <span
    style="WIDTH:1px"></span><input type="button"
    onclick="window.open('DTSNewReqWiz.asp','NewReqWin','width=350,height=250,toolbars=no,statusbar=no')"
    style="MARGIN-TOP:2px; FONT-SIZE:9px; WIDTH:133px;
    BACKGROUND-COLOR:white" value="New Request Wizard">
    </div>
    </div>
    </form>
     
    Luminousc, Mar 23, 2005
    #1
    1. Advertising

  2. Luminousc

    Erwin Moller Guest

    Luminousc wrote:

    > I get the dreaded, 'is null or not an object' at runtime. This happens
    > on the:
    > " if (SearchAndNavFormID.QuickSrchID.value != "") " line.


    Well, that code gives me a headache too. :p

    In general: Do a sanitycheck.
    It helps me always when confused

    So before the 'if':
    alert ("SearchAndNavFormID = "+SearchAndNavFormID);
    alert ("SearchAndNavFormID.QuickSrchID = "+SearchAndNavFormID.QuickSrchID);

    What does that say?
    Is it what you expect?
    Maybe some double names?

    Good luck.

    Regards,
    Erwin Moller
     
    Erwin Moller, Mar 23, 2005
    #2
    1. Advertising

  3. Luminousc

    Mick White Guest

    Luminousc wrote:

    > I get the dreaded, 'is null or not an object' at runtime. This happens
    > on the:
    > " if (SearchAndNavFormID.QuickSrchID.value != "") " line.
    >

    [snip]
    if (document.getElementById("QuickSrchID").value != "")

    or assign names to your form and its elements:

    document.forms["formName"].elements["elementName"].value

    Mick
     
    Mick White, Mar 23, 2005
    #3
  4. Luminousc

    Luminousc Guest

    Yeah, tried that, I had scope of the both the Form and the fields in
    the IDE, but at the page level only the form was visible.

    I ended up short circuiting the issue and writing the javascript
    directly into the onblur command:

    onblur="if (QuickSrchID.value != ''){ViewTypeID.disabled=true;
    ViewTypeID.selectedIndex=ViewTypeID.length-1;}else{ViewTypeID.disabled=false;}"

    Don't know why it works there, but moving it to a separate function
    and adding the 'SearchAndNavFormID.' to the front doesn't but it
    doesn't matter now. This method isn't as elegant but it works.

    Thanks guys for your ultra-fast answers, I posted this query in Google
    Groups and had to wait until it appeared before I could post my
    response.

    Craig

    Erwin Moller <> wrote in message news:<4241774d$0$148$4all.nl>...
    > Luminousc wrote:
    >
    > > I get the dreaded, 'is null or not an object' at runtime. This happens
    > > on the:
    > > " if (SearchAndNavFormID.QuickSrchID.value != "") " line.

    >
    > Well, that code gives me a headache too. :p
    >
    > In general: Do a sanitycheck.
    > It helps me always when confused
    >
    > So before the 'if':
    > alert ("SearchAndNavFormID = "+SearchAndNavFormID);
    > alert ("SearchAndNavFormID.QuickSrchID = "+SearchAndNavFormID.QuickSrchID);
    >
    > What does that say?
    > Is it what you expect?
    > Maybe some double names?
    >
    > Good luck.
    >
    > Regards,
    > Erwin Moller
     
    Luminousc, Mar 24, 2005
    #4
  5. Luminousc

    Erwin Moller Guest

    Luminousc wrote:

    > Yeah, tried that, I had scope of the both the Form and the fields in
    > the IDE, but at the page level only the form was visible.
    >
    > I ended up short circuiting the issue and writing the javascript
    > directly into the onblur command:
    >
    > onblur="if (QuickSrchID.value != ''){ViewTypeID.disabled=true;
    >

    ViewTypeID.selectedIndex=ViewTypeID.length-1;}else{ViewTypeID.disabled=false;}"
    >


    Ok, good you fixed it.

    > Don't know why it works there, but moving it to a separate function
    > and adding the 'SearchAndNavFormID.' to the front doesn't but it
    > doesn't matter now. This method isn't as elegant but it works.
    >
    > Thanks guys for your ultra-fast answers, I posted this query in Google
    > Groups and had to wait until it appeared before I could post my
    > response.


    Download a newsreader.
    Much more comfortable than googlegroups.
    :)
    Some popular choices:

    On GNU/Linux: (I use KNode)
    On W$: chek this:
    http://www.newsreaders.com/win/clients.html

    When I am on W$-box I use Agent:
    get it here:
    http://www.forteinc.com/agent/index.php

    Regards,
    Erwin Moller

    >
    > Craig
    >
     
    Erwin Moller, Mar 25, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    0
    Views:
    344
    darrel
    Jun 21, 2004
  2. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: need second pair of eyes: databinder.eval problem

    Phil Winstanley [Microsoft MVP ASP.NET], Jun 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    432
    darrel
    Jun 21, 2004
  3. DaLoverhino

    J2ee: need another pair of eyes.

    DaLoverhino, Nov 22, 2005, in forum: Java
    Replies:
    1
    Views:
    388
    HalcyonWild
    Nov 22, 2005
  4. Harlin Seritt
    Replies:
    1
    Views:
    298
    Scott David Daniels
    Dec 5, 2005
  5. Laiverd.COM
    Replies:
    9
    Views:
    102
    Richard Cornford
    Aug 5, 2004
Loading...

Share This Page