Results 1 to 4 of 4

Thread: document.form1.select1 is null or not an object

  1. #1
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default document.form1.select1 is null or not an object

    1) Script Title: Menu and Navigation > Drop down menu with description

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...bodescribe.htm

    3) Describe problem: It works everywhere Mac and PC. The problem is I keep getting an Error on Page alert at the bottom of the browser. It says, "document.form1.select1 is null or not an object". This only shows up in IE 7.0 and 6.0 on the PC.

    I'm not using the text below the drop down portion of this code.

    Thanks.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Since you're not showing the descriptions for each combo box, you need to disable the portion of the script that tries to write to the SPAN that came with the script. Find the two lines:
    Code:
    //if (document.getElementById)
    //document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
    Notice how they're commented out now, disabling it.

  3. #3
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank You!

  4. #4
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I removed the code you mentioned and I still get the error in IE 7.0 & IE 6.0 on the PC. If I hit refresh after the page loads it goes away.

    I put my code below.

    Javascript in a separate .js file
    /***********************************************
    * Drop down menu w/ description- © Dynamic Drive (www.dynamicdrive.com)
    * This notice must stay intact for use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    function displaydesc(which, descriptionarray, container){
    }

    function jumptolink(what){
    var selectedopt=what.options[what.selectedIndex]
    if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
    window.open(selectedopt.value)
    else
    window.location=selectedopt.value
    }

    //2) Call function displaydesc() for each drop down menu you have on the page
    // This function displays the initial description for the selected menu item
    // displaydesc(name of select menu, name of corresponding text array, ID of SPAN container tag):
    // Important: Remove the calls not in use (ie: 2nd line below if there's only 1 menu on your page)

    displaydesc(document.form1.select1)
    displaydesc(document.form2.select2)

    // end of drop down menu


    Here's the html
    <form name="form1" style="padding-left:13px;"><select name="select1" size="1" onChange="displaydesc(document.form1.select1)">
    <option selected value="aboutus/michaelodonnell.php">Alabama</option>
    <option value="aboutus/jeffgray.php">Alaska</option>
    <option value="aboutus/jeffgray.php">Arizona</option>
    <option value="aboutus/michaelodonnell.php">Arkansas</option>
    <option value="aboutus/jeffgray.php">California</option>
    <option value="aboutus/johnkevin.php">Colorado</option>
    <option value="aboutus/dougtibbs.php">Connecticut</option>
    <option value="aboutus/gregoryreba.php">Delaware</option>
    <option value="aboutus/petetorell.php">Florida</option>
    <option value="aboutus/michaelodonnell.php">Georgia</option>
    <option value="aboutus/jeffgray.php">Hawaii</option>
    <option value="aboutus/jeffgray.php">Idaho</option>
    <option value="aboutus/joanzaleski.php">Illinois</option>
    <option value="aboutus/joanzaleski.php">Indiana</option>
    <option value="aboutus/kevinthomas.php">Iowa</option>
    <option value="aboutus/johnkevin.php">Kansas</option>
    <option value="aboutus/joanzaleski.php">Kentucky</option>
    <option value="aboutus/kevinthomas.php">Louisiana</option>
    <option value="aboutus/dougtibbs.php">Maine</option>
    <option value="aboutus/gregoryreba.php">Maryland</option>
    <option value="aboutus/dougtibbs.php">Massachusetts</option>
    <option value="aboutus/joanzaleski.php">Michigan</option>
    <option value="aboutus/johnweber.php">Minnesota</option>
    <option value="aboutus/michaelodonnell.php">Mississippi</option>
    <option value="aboutus/johnweber.php">Missouri</option>
    <option value="aboutus/jeffgray.php">Montana</option>
    <option value="aboutus/johnkevin.php">Nebraska</option>
    <option value="aboutus/jeffgray.php">Nevada</option>
    <option value="aboutus/dougtibbs.php">New Hampshire</option>
    <option value="aboutus/gregoryreba.php">New Jersey</option>
    <option value="aboutus/kevinthomas.php">New Mexico</option>
    <option value="aboutus/gregoryreba.php">New York</option>
    <option value="aboutus/michaelodonnell.php">North Carolina</option>
    <option value="aboutus/johnweber.php">North Dakota</option>
    <option value="aboutus/gregoryreba.php">Ohio</option>
    <option value="aboutus/kevinthomas.php">Oklahoma</option>
    <option value="aboutus/jeffgray.php">Oregon</option>
    <option value="aboutus/gregoryreba.php">Pennsylvania</option>
    <option value="aboutus/dougtibbs.php">Rhode Island</option>
    <option value="aboutus/michaelodonnell.php">South Carolina</option>
    <option value="aboutus/johnweber.php">South Dakota</option>
    <option value="aboutus/michaelodonnell.php">Tennessee</option>
    <option value="aboutus/kevinthomas.php">Texas</option>
    <option value="aboutus/jeffgray.php">Utah</option>
    <option value="aboutus/dougtibbs.php">Vermont</option>
    <option value="aboutus/gregoryreba.php">Virginia</option>
    <option value="aboutus/jeffgray.php">Washington</option>
    <option value="aboutus/gregoryreba.php">Washington D.C.</option>
    <option value="aboutus/gregoryreba.php">West Virginia</option>
    <option value="aboutus/joanzaleski.php">Wisconsin</option>
    <option value="aboutus/johnkevin.php">Wyoming</option>
    </select>&nbsp;<input type="button" value="Go" onClick="jumptolink(document.form1.select1)"/>
    </form>
    <form name="form2" style="padding-left:13px;"><select name="select2" size="1" onChange="displaydesc(document.form2.select2)">
    <option value="aboutus/jeffgray.php">Jeff Gray</option>
    <option value="aboutus/davemccoy.php">Dave McCoy</option>
    <option value="aboutus/michaelodonnell.php">Michael O'Donnell</option>
    <option value="aboutus/gregoryreba.php">Gregory Reba</option>
    <option value="aboutus/patstimers.php">Pat Stimers</option>
    <option value="aboutus/kevinthomas.php">Kevin Thomas</option>
    <option value="aboutus/dougtibbs.php">Douglas Tibbs</option>
    <option value="aboutus/petetorell.php">Pete Torell</option>
    <option value="aboutus/johnweber.php">John Weber </option>
    <option value="aboutus/johnworthing.php">John Worthing</option>
    <option value="aboutus/joanzaleski.php">Joan Zaleski</option>
    </select>&nbsp;<input type="button" value="Go" onClick="jumptolink(document.form2.select2)"/></form>

    Thanks.

Bookmarks

Posting Permissions

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