By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,773 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,773 IT Pros & Developers. It's quick & easy.

getElementsByTagName and doctype

P: 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.

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.