473,568 Members | 3,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

3 lines of code want to display all tags

for(var i=0;i<document. all.elements.le ngth;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 4844
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**@gladsto ne-inc.com> wrote in message
news:vo******** ****@corp.super news.com...
for(var i=0;i<document. all.elements.le ngth;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.ge tElementsByTagN ame("*");

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.m u> 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.ge tElementsByTagN ame("*");

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
2445
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, (anchor, image, table...etc). for example, if I have some text... $text = "<a href='somelonnnnnnngg'>this is a small text</a>";
4
4119
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 javascript, I get an "error on page" warning and the page is not displayed. I suppose that when Internet Explorer discovers a <script> tag he starts...
4
4003
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"> function alt() { document.all.s1.innerHTML="Current Temp: 68°F"; var txt=document.all.s1.innerText; alert(txt); }
33
2326
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: http://xahlee.org/UnixResource_dir/writ/truncate_line.html
7
2848
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 custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could,...
9
3163
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 want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form,...
1
1631
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 different cells (<td>...</td>). In other words, if there are 14 records in the DB table, the HTML table should display the 14 records in 2 rows - the 1st...
7
15630
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 there an equivalent property for the DataGridView? I have searched, but have not found one. I would like the user to be able to see all the columns...
1
1839
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 know how I can add blank lines to a form. If I use response.write it writes to the body of the HTML and not inside the form. I am sure it must be...
0
7692
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7913
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.