SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Norcross, GA
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript: object not recognized, even though it's clearly there

    The error is 'document.callentry.whoathere is not an object'

    Code:
    <html><head><title></title></head>
    <body>
    <p>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Beginning of JavaScript --------
    
    var strMsg = 'Leaving this page without using the Submit button will cause your narritave to be lost.' 
    if (document.whoathere.value==0) {
    	window.event.returnValue = strMsg; 
    } 
    	
    // -- End of JavaScript code -------------- -->
    </SCRIPT>
    <form name="callentry" method="post" action="process_callentry.phtml">
    <input type="hidden" name="fnum" value="p9999998">
    <input type="text" name="whoathere" value="0">
    <input type=submit value='Submit' onClick="document.callentry.whoathere.value=1;">
    </form>
    </body>
    </html>
    I've tried replacing the form name (in the script) with form[0] but the same error appeared (documet.forms.0.whoathere is not an object).

    Any clues?
    Last edited by mstembri; Feb 7, 2002 at 10:13.

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Norcross, GA
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved.

    I changed the <SCRIPT LANGUAGE="JavaScript"> tag to this:

    <SCRIPT LANGUAGE=JavaScript FOR=window EVENT=onbeforeunload>

    And now the script works perfectly.
    - Mike
    http://www.georgiaoffroad.com

  3. #3
    pg for mild peril cow's Avatar
    Join Date
    Mar 2000
    Location
    nevada, usa
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the for and event elements in the script tag are only valid in ie. have you tried to test this script in netscape?
    "There's no justice like angry mob justice!" --Seymour Skinner

  4. #4
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It seems the problem is this:

    Code:
    var strMsg = 'Leaving this page without using the Submit button will cause your narritave to be lost.' 
    if (document.whoathere.value==0) {
    	window.event.returnValue = strMsg; 
    }
    in the document.whoathere.value , it's not referencing the form.

    it should be document.callentry.whoathere.value


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
  •