Separate Values by Table In Javascript



I have created a table in Javascript using this.find() to parse through XML from a third party source using an AJAX call.



$('<tr>').html("<td class = 'dispatch late OBC-User' onclick='TripInfo(" + $(this).find("TripID").text() + ");'>" + "TripID: " + $(this).find("TripID").text() + "<br>"
+ "ETA: " + "Completed on<br /> " + monthArray[theMonth2] + " " + $(this).find("ArriveDate").text().substr(8, 8).replace('T', ' at ')
+ "<br>" + "DepartTime: " + monthArray[theMonth] + " " + $(this).find("DepartDate").text().substr(8, 8).replace('T', ' - ')
+ "</td>".appendTo('#itemTable2');


The output puts everything into one table as follows:



TripID: 272326
ETA: Completed on
July 31 at 14:34
DepartTime: July 31 - 14:31
TripID: 272344
ETA: Completed on
July 30 at 04:00
DepartTime: July 30 - 02:20


How would I give them their own tables? For example, TripID: 272326 and the ETA/DepartTime after it should be in one table and the next TripID with ETA/DepartTime should be in another table.


Would this be done using a for-each loop? Or is there another way? Thanks, I am relatively new to Javascript/AJAX.


No comments:

Post a Comment