By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,453 Members | 3,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,453 IT Pros & Developers. It's quick & easy.

Is it possible to make dynamic ids for html-tags

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a


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.