Here , I have 10 Json Objects . I am trying to add a scroll bar on the table with overflow:auto
But here is a twist ,What i exactly want is the moment my scroll bar hit the bottom , i want to put a condition something like the upper 10 values repeats again but only when the scroll bar hits the bottom and i want it in a infinite loop.
What i did so far Here I put the JSON objects inside the array.
var response = [
{
"CategoryName":"Beverages",
"ProductName":"Steeleye Stout"
},
{
"CategoryName":"Beverages",
"ProductName":"Laughing Lumberjack Lager"
},
{
"CategoryName":"Beverages",
"ProductName":"Lakkalik\u00f6\u00f6ri"
},
{
"CategoryName":"Beverages",
"ProductName":"Guaran\u00e1 Fant\u00e1stica"
},
{
"CategoryName":"Beverages",
"ProductName":"Ipoh Coffee"
},
{
"CategoryName":"Beverages",
"ProductName":"Chang"
},
{
"CategoryName":"Beverages",
"ProductName":"Chartreuse verte"
},
{
"CategoryName":"Beverages",
"ProductName":"Ipoh Coffee"
},
{
"CategoryName":"Beverages",
"ProductName":"Chai"
},
{
"CategoryName":"Beverages",
"ProductName":"Chang"
}
]
Now i created i table but i also want a change in it too, i just want 5 entries in first place .Next five ,i want to access from the scroll bar.
var key = [];
document.write("<table border==\"1\"><tr>");
for (key in response[0]) {
document.write('<td>' + '<b>' + key + '</b>' + '</td>');
}
document.write("</tr>");
for (var i = 0; i < response.length; i++) {
document.write('<tr>');
for (key in response[i]) {
document.write('<td>' + response[i][key] + '</td>');
}
document.write('</tr>');
}
document.write("</table>");
I hope you guys understand what i wanted to ask. Thanks in advance :)