function saveBooking(){
var booking = {
tableNo : $('#table_no').val(),
customer : $('#customer').val(),
seats : $('#seats').val(),
cost : $('#cost').val()
}
/*for(i=0;i<booking.length;++i){
document.write(booking[i]);
}*/
}
Page 1 of 1
Print two-dimensional array
#1
Posted 18 January 2012 - 11:46 AM
Hi, I wish to know how to print out a two-dimensional array with a for loop, I know how to do this with a single array but unsure with two-dimensional.
#2
Posted 18 January 2012 - 12:01 PM
That's not a 2D array, it's a JavaScript object. Either way, you can iterate through it using jQuery like so:
$.each(booking, function(key, val){
document.write(key + ": " + val);
});
Share this topic:
Page 1 of 1
Help














