|
-
Dec 10th, 2004, 05:03 AM
#1
Thread Starter
Junior Member
document.innerHTML
Hi
I am trying to create a javascript that will tell me all the "ID"s associated with the HTML tags as I can change them later by getElementById() method
for example
instead of writing
document.getElementById("myid").innerHTML = "<b>Hello World</b>"
I want to write
var var_myID
var_myID = Some code that can dinamically find any "ID" associated with any TAG
document.getElementById(var_myID).innerHTML = "<b>Hello World</b>"
can any one suggest me any idea
kajol
-
Dec 10th, 2004, 10:47 AM
#2
Re: document.innerHTML
I absolutely don't get what you want.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 12th, 2004, 03:28 AM
#3
Re: document.innerHTML
I think she wants to get the ElementID of an element whose ID she's going to change, after it has changed.
Careful... a wormhole might open into another dimension.
-
Dec 13th, 2004, 12:02 PM
#4
Frenzied Member
Re: document.innerHTML
I think what you want is looping through all the tags in a page and extract the ID's from those which have one, and then use that ID to change the innerHTML?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Dec 16th, 2004, 04:50 AM
#5
Thread Starter
Junior Member
Re: document.innerHTML
Hi Jop
this is what I want to do
do you have any solution
kajol
 Originally Posted by Jop
I think what you want is looping through all the tags in a page and extract the ID's from those which have one, and then use that ID to change the innerHTML?
-
Dec 16th, 2004, 05:57 AM
#6
Re: document.innerHTML
But what sense does that make?
I mean, you can use various ways of getting all elements (simplest is document.getElementsByTagName('*')), and the loop through them and look where the id attribute is not empty, but...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 17th, 2004, 02:01 AM
#7
Thread Starter
Junior Member
Re: document.innerHTML
Thanks
I did it with the following code
a = document.all
for( i = 0 ; i < a.length ; i ++ )
{
e = document.getElementsByTagName(a[i].tagName)
for( j = 0 ; j < e.length ; j ++ )
{
if(e[j].id != "")
{
...
...
}
}
}
kajol
 Originally Posted by CornedBee
But what sense does that make?
I mean, you can use various ways of getting all elements (simplest is document.getElementsByTagName('*')), and the loop through them and look where the id attribute is not empty, but...
-
Dec 17th, 2004, 07:05 AM
#8
Re: document.innerHTML
Whoa, this inner loop runs, well, hard to calculate, but FAR more often than it needs to. And you artificially made it IE-only.
Code:
e = document.getElementsByTagName('*')
for( j = 0 ; j < e.length ; j ++ )
{
if(e[j].id != "")
{
...
...
}
}
This suffices completely.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|