473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.

Jul 23 '05 #1
1 1570
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some...
23
by: Michel Bany | last post by:
I am trying to parse responseXML from an HTTP request. var doc = request.responseXML; var elements = doc.getElementsByTagName("*"); the last statement returns an empty collection when running from...
3
by: Andy | last post by:
Hello, I have the following example XML: <data> <package> <packageid>123</packageid> <package_article> <articleid>article1</articleid> </package_article> </package>
7
by: Dima | last post by:
Call to XmlNode.GetElementsByTagName returns XmlNodeList that stays in sync with XmlDocument thanks to events fired by XmlDocument. Once this list is created there is no way to remove its event...
1
by: Max | last post by:
Hello everyone! i would want to know if the getElementsByTagName() function starts to find the elements from documentElement comprising the same documentElement. XML example: <?xml...
1
by: Ben | last post by:
I have a web service that returns the following xml: <?xml version="1.0" encoding="utf-8" ?> <NewDataSet> <Addresses> <XML_F52E2B61-18A1-11d1-B105-00805F49916B> <CustomerAddressBase...
3
by: windandwaves | last post by:
does it matter if I write var anchors = document.getElementsByTagName("A"); or var anchors = document.getElementsByTagName("a"); Or is there a better way to catch both <a hrefs and <A...
5
by: eBob.com | last post by:
I am so frustrated. I've been working all weekend on what I thought would be a simple script. I never find it easy to look at someone else's code, but if someone can help with this I would be...
5
by: Andy Chambers | last post by:
Hi, On both Opera and Firefox, getElementsByTagName doesn't find anything apart from <optionelements inside a select element. Why is this? Here's a page that demonstrates this behaviour. I'd...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.