473,395 Members | 1,532 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,395 software developers and data experts.

3 lines of code want to display all tags

for(var i=0;i<document.all.elements.length;i++){
alert(document.forms[0].elements[i].id);
}

This code displays the ids of only controls in a form, but I'd like it to
display ALL items. For example, not just the ids of buttons, inputs, etc,
but any <span> elements as well. Is there something I could replace with
the "elements"? I tried tags but that doesn't work either.

Thanks!
Mike
Jul 20 '05 #1
3 4838
I figured it out. Here is the code:

for(var i=0;i<document.all.length;i++){
alert(document.all[i].id);
}
"Mike Hnatt" <do**@gladstone-inc.com> wrote in message
news:vo************@corp.supernews.com...
for(var i=0;i<document.all.elements.length;i++){
alert(document.forms[0].elements[i].id);
}

This code displays the ids of only controls in a form, but I'd like it to
display ALL items. For example, not just the ids of buttons, inputs, etc,
but any <span> elements as well. Is there something I could replace with
the "elements"? I tried tags but that doesn't work either.

Thanks!
Mike

Jul 20 '05 #2
Mike Hnatt wrote:
I figured it out. Here is the code:

for(var i=0;i<document.all.length;i++){
alert(document.all[i].id);
}


This is deprecated and does not work in every browser.
You should try a better way for this:

var all=document.getElementsByTagName("*");

for(var i=0; i<all.length; i++)
alert(all[i].id);

--
marcoos.org

Jul 20 '05 #3
Thanks Marek, I made the changes. I appreciate it,
Mike

"Marek A. Stepien" <ma******@spa.mu> wrote in message
news:bm**********@nemesis.news.tpi.pl...
Mike Hnatt wrote:
I figured it out. Here is the code:

for(var i=0;i<document.all.length;i++){
alert(document.all[i].id);
}


This is deprecated and does not work in every browser.
You should try a better way for this:

var all=document.getElementsByTagName("*");

for(var i=0; i<all.length; i++)
alert(all[i].id);

--
marcoos.org

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sims | last post by:
Hi, I know how to limit the number of characters using substr, (http://uk.php.net/manual/en/function.substr.php). But when using html that is not going to work because of all the possible tags,...
4
by: hoke | last post by:
I want to display plain text files in the browser. The files contain html and javascript and have a .txt extension. This works fine with files with just html. Unfortunately when showing files with...
4
by: hugo2 | last post by:
Most of these characters are not on the standard keyboard. Here's a successful contrivance, with comments & cautions, a little page that works in IE6. <HTML><HEAD><SCRIPT TYPE="text/javascript">...
33
by: Xah Lee | last post by:
The Harm of hard-wrapping Lines 20050222 Computing Folks of the industry: please spread the debunking of the truncating line business of the fucking unix-loving fuckheads, as outlines here:...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
1
by: rn5a | last post by:
I want an ASP app to retrieve records from a MS-Access database table but display them in a HTML table but I want the HTML table table to display only 7 records in a row (<tr>...</tr>) in 7...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
1
by: CapRand | last post by:
Hi, I am creating an ASP.NET site and have created a form which I have been able to dynamically with listboxes, labels etc from a database - using mainly form1.Controls.Add ..... Does anyone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.