Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Trying to clean up my code of "Warnings"



2:06 pm on Nov 3, 2005 (gmt 0)

10+ Year Member

I'm trying to learn JavaScript and at same time trying to make it W3C standard. That way I will develop a good habit in creating a validable web pages. I'm trying to figure out how to fix this code:


When I opened JavaScript Console in firefox, I get the error:

Warning: Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.

And my form looks like this:

<form action="khours.asp" method="post" name="krono_process" onsubmit="return validateKronos(this);" autocomplete="off">

Oh, one more thing -- 'autocomplete="off"' isn't validated, what is the alternative for it? This web page will be used for data entry and I do not want autocomplete to interfer their operations.

Bernard Marx

2:53 pm on Nov 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Using full W3C standard script to get a select element's selection is tricky, and probably involves some messing about to get all browsers to conform. I'll have to look deeper sometime. The warning isn't necessarily about not using fully W3C DOM1 interface code, it's just that you are relying on using the form's name as a global reference.

Either of these 2 statements should make the warning go away:

a) Using older, "document collections", code:

You have sent a ref to the form to the function:

onsubmit="return validateKronos(this);" 

Let's assume that you have this:

function validateKronos(form)


if( form.elements.assocID.options[0].selected )

b) A mixture of older and newer code

if( document.getElementsByName('assocID')[0].getElementsByTagName('option')[0].selected)

RE: autocomplete

a) Write a new DTD for your document
b) Simply ignore validator warnings about this particular invalid attribute. Browsers don't validate documents anyway.


3:12 pm on Nov 3, 2005 (gmt 0)

10+ Year Member

Hmm.. DTD -- I would like to learn that. Where can I get started for that part?

I already changed my document to conform your a. part suggestion, at least for now. I'm using Firefox, IE (all versions), Opera and lynx (paramount important) to test my application development. Warning went away except for document part.

Bernard Marx

3:32 pm on Nov 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Don't know much about DTD's. Considering browsers don't generally download DTDs anyway, it seems a bit pedantic. Yet, if you like, there are a few texts on it:


In XHTML 1.1 one should be able to add a small module.

Warning went away except for document part.



Featured Threads

Hot Threads This Week

Hot Threads This Month