gwmbox
05-28-2010, 04:05 AM
Hi all
I asked for a sequential number before for a list, when in fact I need an increment method to add to a class. Sorry if this is regarded as a double post but I don't think my original request was correct.
so anyway...
If I have a list being generated by a javascript on the fly and I want to add a unique class reference to each list item how would I do that. I have the list being generated but cannot work out how to add a class reference to each item that is an increment for each list item called. I have been reading about javascript increment and that seems to be what I need but my results keep coming back with just the first item incremented and then each subsequent list item is the same number
I'm going to assume I need some form of loop or for each method so that as each list item is generated it looks at the javascript and gets the next number for that list. The result would end up with a list with classes like;
<ul id="mylist">
<li class="someclass_1">Text</li>
<li class="someclass_2">Text</li>
<li class="someclass_3">Text</li>
<li class="someclass_4">Text</li>
</ul>
It is the 1, 2, 3 and 4 I need to have added to the class, but that list numbers are different in number from time to time, so the list might have 6, 8, or even 10 items in it. The max would be 10 so if it would be easier to just insert via js then maybe that would be easier???
Thanks for your help
I asked for a sequential number before for a list, when in fact I need an increment method to add to a class. Sorry if this is regarded as a double post but I don't think my original request was correct.
so anyway...
If I have a list being generated by a javascript on the fly and I want to add a unique class reference to each list item how would I do that. I have the list being generated but cannot work out how to add a class reference to each item that is an increment for each list item called. I have been reading about javascript increment and that seems to be what I need but my results keep coming back with just the first item incremented and then each subsequent list item is the same number
I'm going to assume I need some form of loop or for each method so that as each list item is generated it looks at the javascript and gets the next number for that list. The result would end up with a list with classes like;
<ul id="mylist">
<li class="someclass_1">Text</li>
<li class="someclass_2">Text</li>
<li class="someclass_3">Text</li>
<li class="someclass_4">Text</li>
</ul>
It is the 1, 2, 3 and 4 I need to have added to the class, but that list numbers are different in number from time to time, so the list might have 6, 8, or even 10 items in it. The max would be 10 so if it would be easier to just insert via js then maybe that would be easier???
Thanks for your help