Is it possible to make dynamic ids for html-tags

O

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?
 
M

Martin Honnen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top