iPixel Posted October 29, 2009 Share Posted October 29, 2009 Ok so i've got these <tr>'s with ID's such as xDates_0000_1 xDates_0000_2 xDates_0000_3 xDates_0000_4 xDates_0000_5 You get the idea, the example ended at _5 but i could have much more or much less, that part i dont really know. is there a way in JS to loop and check for ID's and once an ID is not found stop? Or in other words look for ID's till you cant find one. So the loop will go.. looking for ID xDates_0000_1 --- YAY found it ---- Do this and that looking for ID xDates_0000_2 --- YAY found it ---- Do this and that looking for ID xDates_0000_3 --- Hmm cant find it ---- Ok exit and go on... Thanks Quote Link to comment Share on other sites More sharing options...
Adam Posted October 30, 2009 Share Posted October 30, 2009 You could do it like so: var i = 1; while (obj = document.getElementById('xDates_0000_' + i)) { // do this and that i++; } // carry on Quote Link to comment Share on other sites More sharing options...
iPixel Posted October 30, 2009 Author Share Posted October 30, 2009 Perfect! Thank You! This works exactly how i needed it to. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.