Connecting Tech Pros Worldwide Help | Site Map

getElementsByTagName and doctype

  #1  
Old July 23rd, 2005, 08:05 PM
otto
Guest
 
Posts: n/a
I'm a little new to the new DOM and using getElementsByTagName.
I'm trying to write code that returns an input tag based on its name
(for the sake of this example, I'm calling it xyz.)

I'm trying the following code:

function getxyx(){
var checks = document.getElementsByTagName('input');
for(var i=0;i<=checks.length;i++){
if(/xyz/.test(checks[i].getAttribute('name'))){
var mycheckbox = checks[i];
}
}
return mycheckbox;
}

The problem is that checks.length is returning 0. The html document
doesn't have any doctype at the moment. What doctype(s) can I use? Is
there a better way to do this?

Thanks.

  #2  
Old July 23rd, 2005, 08:06 PM
otto
Guest
 
Posts: n/a

re: getElementsByTagName and doctype


Nevermind. I figured it out. It wasn't the doctype at all. It had to do
with the fact that I was calling the script from window.onload, but it
was attached to a cgi which was not buffering as it rendered. In other
words, the input collection was not yet present when the javascript
function was called.

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
XmlDocument.save bug? Appending [] to the doctype Stephen Ward answers 3 August 8th, 2008 07:55 PM
var anchors = document.getElementsByTagName("A"); windandwaves answers 3 January 25th, 2007 06:35 PM
DOCTYPE detector Jim Michaels answers 24 August 7th, 2006 08:55 PM
VS2005 and DOCTYPE in Web Forms Chris Botha answers 6 November 21st, 2005 07:15 PM