468,509 Members | 1,335 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,509 developers. It's quick & easy.

Is it possible to make dynamic ids for html-tags

OM

I am trying to present tree-structure information using a html table
and JavaScript. Each tree node is displayed in the first column in a
table row. The tree node can also have additional information in
other table columns.

To make the collapse / expand functionality I want to use JavaScript
to display / hide table rows using row.style.display = "inline" /
"none".

To get references to the table rows they all need unique id's. I want
the root node to have id="1", the nodes on the second level should
have id="1.1", "1.2", "1.3", the nodes on the third level should have
id="1.1.1", "1.1.2", "1.1.3" etc.

id=1
id=1.1
id=1.1.1
id=1.1.2
id=1.2
id=1.2.1

The html code is made using a repeater (<netui:repeater>). Is it
possible to give the table rows dynamic ids as I loop through the
repeater?

-------
OM
Jul 23 '05 #1
1 3141


OM wrote:

To make the collapse / expand functionality I want to use JavaScript
to display / hide table rows using row.style.display = "inline" /
"none".
Be aware that CSS 2 requires
table-row
and not
inline
for table row elements thus if you want to script table rows in Mozilla
for instance then you shouldn't use inline but use table-row as the
value for the CSS display property.
To get references to the table rows they all need unique id's. I want
the root node to have id="1", the nodes on the second level should
have id="1.1", "1.2", "1.3", the nodes on the third level should have
id="1.1.1", "1.1.2", "1.1.3" etc.

id=1
id=1.1
id=1.1.1
id=1.1.2
id=1.2
id=1.2.1

The html code is made using a repeater (<netui:repeater>). Is it
possible to give the table rows dynamic ids as I loop through the
repeater?


Yes, why not, but there are rules for id attribute values, see here
<http://www.w3.org/TR/html4/struct/global.html#h-7.5.2>
<http://www.w3.org/TR/html4/types.html#type-name>
so you need to start an id attribute value with a letter a-zA-Z.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by SAN CAZIANO | last post: by
3 posts views Thread by Aaron Gervais | last post: by
reply views Thread by Amy B | last post: by
reply views Thread by Mark Rae | last post: by
reply views Thread by robert112 | last post: by
3 posts views Thread by gieforce | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.