Connecting Tech Pros Worldwide Help | Site Map

getElementsByTagName and doctype

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 07:05 PM
otto
Guest
 
Posts: n/a
Default getElementsByTagName and doctype

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, 07:06 PM
otto
Guest
 
Posts: n/a
Default 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.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.