SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error: uncaught exception --- HELP!!!

    I'm getting this JavaScript error in Netscape:

    Error: uncaught exception: Permission denied to get property HTMLDivElement.parentNode

    Other than the JS error, the code works the way I want it to. I didn't write the code, and Netscape isn't giving a line number, so am not sure where exactly the code is generating this error.

    One other thing to note is that I get this javascript error as soon as I tab out of the input box. See the HTML code in the "21:52" message...

    Thanks...
    Last edited by casa; Jan 8, 2004 at 15:57.

  2. #2
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what happened, but all the sudden the javascript error went away.

    Actually, it didn't go away, see below:
    Last edited by casa; Jan 8, 2004 at 15:58.

  3. #3
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay, I figured out that the error doesn't have anything to do with my JavaScript, but is another problem that I really don't understand.

    I don't know what's going on. I brought the form page up, typed java_script_: in the address bar then sized both windows so I could see them at the same time. I am getting this error when I click in an input box, not when I tab between boxes. If this was for a personal or freelance site, I'd just forget it, but it's site that is really strict about javascript errors and 508 compliance and HTML validation. All the sites have to pass a site board where they go through everything with a fine tooth comb and javascript error are one thing that will get your site sent back toot-sweet. (for everyone out there under 40, that means really quick ).
    Last edited by casa; Jan 8, 2004 at 16:00.

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The error message is unrelated to the posted code, afaik.

    You have some invalid HTML ('<td<input...') as well as <th> elements within the table body. Could be a parsing issue.

    Zip it up & post it, if you like.

    ....modified the former function a bit. Why put the number of field pairs in a hidden field? JS can determine this on its own (while loop/object detection).
    Code:
    function ValAdd(oForm)
    {
    	var first, last, firstbad, lastbad, i = 1, oRegExp = /^\s*$/, focus_me = null, msg = '';
    	while (first = oForm.elements['first' + i])
    	{
    		last = oForm.elements['last' + i];
    		firstbad = oRegExp.test(first.value);
    		lastbad = oRegExp.test(last.value);
    		if (firstbad)
    			msg += '\nEmployee #' + i + ' - First Name';
    		if (lastbad)
    			msg += '\nEmployee #' + i + ' - Last Name';
    		if (focus_me == null && (firstbad || lastbad))
    			focus_me = (firstbad) ? first : last;
    		++i;
    	}
    	if (msg != '')
    	{
    		msg = 'Please complete the following entries:\n' + msg + '\n\nThank you.';
    		alert(msg);
    		if (focus_me)
    		{
    			focus_me.focus();
    			focus_me.select();
    		}
    		return false;
    	}
    	return true;
    }
    ::: certified wild guess :::

  5. #5
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had figured out that the error was outside the javascript when I posted last. The HTML errors were from me removing some code for ease of viewing. I will post the actual code and let you see what you think. However, I ran it throu CSE HTML Validator and it came up with no errors.

  6. #6
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the html code generation:
    PHP Code:
    <?php
        
    for ($i=1$i <= $numEmp$i++) {
    ?>
    <tr>
    <?php
         
    if ($numEmp == 1) { $count ""; }
    else             { 
    $count $i.".&nbsp;&nbsp;";}
    ?>
    <th align="right" 
        class="text12" 
        scope="row" 
        abbr="employeefirstname<?=$i?>
        id="employeefirstname<?=$i?>">
    <img src="[url="http://mi.msfc.nasa.gov/CSTTdev/images/star.gif"]/images/star.gif[/url]" height="12" width="7" alt="Name is required" />&nbsp;
    <label for="firstname<?=$i?>"><?=$count?>&nbsp;First:</label>
    </th>
    <td align="left" 
        class="text12" 
        headers="employeefirstname<?=$i?>">
    <input id="firstname<?=$i?>
        type="text" 
        name="first<?=$i?>
        value="<?=$firstH?>
        size="<?=$s15?>" />
    </td>
    <th align="right" 
        class="text12" 
        scope="row" 
        abbr="employeelastname<?=$i?>
        id="employeelastname<?=$i?>">&nbsp;
    <label for="lastname<?=$i?>">Last:</label>
    </th>
    <td align="left" 
        class="text12" 
        headers="employeelastname<?=$i?>">
    <input id="lastname<?=$i?>
        type="text" name="last<?=$i?>
        value="<?=$lastH?>
        size="<?=$s15?>" />
    </td>
    </tr>
    <?php
        
    }
    ?>
    producing this html for 2 where empNum = 2:
    Code:
    <tr>
    <th align="right" 
    	class="text12" scope="row" 
    	abbr="employeefirstname1" 
    	id="employeefirstname1">
    <img src="/images/star.gif" height="12" width="7" alt="Name is required" />&nbsp;
    <label for="firstname1">1.&nbsp;&nbsp;&nbsp;First:</label>
    </th>
    <td align="left" 
    	class="text12" 
    	headers="employeefirstname1">
    <input id="firstname1" 
    	type="text" 
    	name="first1" 
    	value="" size="12" />
    </td>
    <th align="right" 
    	class="text12" 
    	scope="row" 
    	abbr="employeelastname1" 
    	id="employeelastname1">&nbsp;
    <label for="lastname1">Last:</label>
    </th>
    <td align="left" 
    	class="text12" 
    	headers="employeelastname1">
    <input id="lastname1" 
    	type="text" 
    	name="last1" 
    	value="" size="12" />
    </td>
    </tr>
    <tr>
    <th align="right" 
    	class="text12" 
    	scope="row" 
    	abbr="employeefirstname2" 
    	id="employeefirstname2">
    <img src="/images/star.gif" height="12" width="7" alt="Name is required" />&nbsp;
    <label for="firstname2">2.&nbsp;&nbsp;&nbsp;First:</label>
    </th>
    <td align="left" 
    	class="text12" 
    	headers="employeefirstname2">
    <input id="firstname2" 
    	type="text" 
    	name="first2" 
    	value="" size="12" />
    </td>
    <th align="right" 
    	class="text12" 
    	scope="row" 
    	abbr="employeelastname2" 
    	id="employeelastname2">&nbsp;
    <label for="lastname2">Last:</label>
    </th>
    <td align="left" 
    	class="text12" 
    	headers="employeelastname2">
    <input id="lastname2" 
    	type="text" 
    	name="last2" 
    	value="" size="12" />
    </td>
    </tr>
    Like I said before, I ran it through HTML Validator and no errors were picked up that would make any difference. The only error was on my hidden field where I had forgotten to put a / before the >. I fixed that and still, nothing is different. The way I checked the HTML was to render the php created page and then view source and copy that into the validator window and then hit validate normal.

  7. #7
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    adios, I just want to say, thank you for all your help and advice. JavaScript is my weakest area. If I could do it all in PHP, I would, but life is not that easy I just don't see any HTML error in my code.

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi casa [adios is in the casa ]

    Pasted your (generated) HTML in with my function (above) and...works fine. What's not happening on your end?
    ::: certified wild guess :::

  9. #9
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, I don't know. I think I need to put a little javascript in to locate the cursor in the first box. If I hit tab to make it go in there, then I don't get any errors, but just as soon as I take my mouse and click over the first, or any box, I get that error. I don't what happened, but the server that this site lives on crashed about 2 weeks ago and ever since then I've been getting lots of js errors that I wasn't getting before. This site was almost ready for production at Thanksgiving. All it needed was the nod from the board. Now I feel like I'm back at square 1. I don't know if it had anything to do with the crash and restore, but I've had fits with JS and phpMyAdmin ever since. Thanks... casa

  10. #10
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    casa...

    JS exceptions can only be thrown where there is JS running. The only JS I can see above is the form validation; for a click or a focus event to error requires that, somewhere, an event handler must have been assigned to trap one of those events. Is there more scripting on that page?

    Is there a url?
    ::: certified wild guess :::

  11. #11
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll PM it to you.

  12. #12
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    going home before the snow hits.

    we might get as much as an inch. YIKES!

    Friday: Oh too bad, no snow...
    Last edited by casa; Jan 9, 2004 at 08:18.

  13. #13
    SitePoint Enthusiast casa's Avatar
    Join Date
    Oct 2002
    Location
    Alabama
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Adios,

    Please explain to me how this part works:
    Code:
    if (focus_me == null && (firstbad || lastbad))
    focus_me = (firstbad) ? first : last;
    I want to use that with the rest of my validation (which isn't in a loop) so I'm not popping up one error at a time. Did you get the js that I pm'ed you???

    casa

  14. #14
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (focus_me == null && ---> no focus-on-return element assigned yet, and...

    (firstbad || lastbad)) ---> one of this fieldpair is empty, so...

    focus_me = (firstbad) ? first : last; ---> set the variable to a reference to the first(name) field if empty, otherwise the last(name) field

    http://www.webreference.com/js/tips/991110.html

    If you want a validator with one, all-inclusive prompt - a very good idea - you'll need to re-do the entire thing. The methodology is completely different. I could help, but not without a sample form (HTML). I'd use drop-downs for date entry, if possible, to restrict input & avoid complicated validation.
    ::: certified wild guess :::

  15. #15
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    FYI, for everyone else out there wondering what toot-sweet means, that's actually tout suite, taken from the French, tout de suite, meaning "right away"
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  16. #16
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Funny...I always thought a toot suite was where Marion Barry stayed when he was in town.

    beetle...is that your daughter? Très adorable!
    ::: certified wild guess :::

  17. #17
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya, she's mine Merci beacoup!
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •