Click to See Complete Forum and Search --> : how can ui get an elements list?
pelegk1
10-15-2003, 03:56 AM
i have few rows that are made with asp
each row is like this :
<td id="td1">wefqwer</td>
and so on, where the id gt the value of the index in the loop which means :
id="td"+i
how can i know i javascript how many elements of that id i have got?
thanks in advance
peleg
You could just do it in ASP. Keep track of the number of rows you are writing, and when you are done, write that number to a JavaScript variable... If that won't work for you, take a look at this:
<script type="text/javascript">
maxnum = 50; //choose some number heigher than the max number possible
x=0;
function checkNum() {
for (i=0; i<maxnum; i++) {
if (document.getElementById("foo"+i)) {
x++;
}
}
alert (x);
}
onload = checkNum;
</script>
</head>
<body>
<div id="foo1"></div>
<div id="foo2"></div>
<div id="foo3"></div>
Charles
10-15-2003, 08:10 AM
From peleg
Jerusalem - The Capitol City of Israel for ever...That rather reminds me of a line from a song by Meatloaf, "I said I'd love you 'till the end of time. Now I'm waiting for the end of time so I don't have to love you no more."
1) A very considerable number of us on this planet still consider Jerusalem to be the rightful capitol of a free and sovereign Palestine.
2) Such political comments, both yours and mine, are wholly inappropriate for this forum.
lillu
10-15-2003, 08:26 AM
<html>
<head>
<script language="javascript">
function tdCount()
{
var tds = document.getElementsByTagName("TD");
for(var i=0; i<tds.length; i++)_{
if (document.getElementById('td_'+i))
{alert('Count is '+ i); }
}
}
</script>
</head>
<body>
<table border="1">
<tr>
<td id="td_0" onclick="tdCount()">Cell 1</td>
<td id="td_1">Cell 2</td>
</tr>
</table>
</body>
</html>
Khalid Ali
10-15-2003, 10:59 AM
Please refrain from using this forum for religious or culturally controversial statements.Its not the policy of the forum to let this happen.You will for sure end up losing the privilege to post in these forums.
pelegk1
10-16-2003, 01:14 AM
to Charles>?
Khalid Ali
10-16-2003, 01:18 AM
primarily you.
pelegk1
10-16-2003, 01:22 AM
that is my signutare
i dont see it political but the a basic thing for me like
brithing
Charles
10-16-2003, 05:44 AM
Originally posted by pelegk1
that is my signutare
i dont see it political but the a basic thing for me like
brithing Having read the private message you sent me, I see your point. I imagine that such hate as you seem to have becomes a constant friend and something that you don't even notice. Please do not contact me ever again.
pelegk1
10-16-2003, 05:49 AM
you didnt understand even a word of what i wrote!
i dont have any hate against the palestiniens
if you have read between the lines you chould understand that
after i read some news-paper from canada i understand where
your hate to us come's from!