user2910074 user2910074 - 12 days ago 8
HTML Question

How can I quickly give 625 cells an ID?

I'm trying to create a table with 25 rows and 25 columns. I need each

to be assigned a unique ID. To do this manually, I would have to write the id of each
625 times, which is a monotonous task. How can I do this quickly and easily?

I was thinking that I could give each
an ID which is a value between 1 and 25. The ID of each
could then perhaps be given by

*ID of corresponding tr* + "- i"

For integers 0


Yes, your mind is going in the right direction. You could use Javascript or let the html be generated by Razor with an .cshtml and C# in it ... Maybe its easier if you generatre the whole table with JS and do not write the table in pure html and try to modify at later. If you dont want to depend on activated JS you could juse JS to generate the code once and then copy the pure html.

Use some kind of loop and repeat to append some html code via JS

<tbody id="myTable">

<script type="text/javascript">
var i = 0;
while(i < 100)
document.getElementById('myTable').innerHTML += "<tr id='" + i + "'>Hallo</tr>";