I have a big array and I need to render it into a table. Instead of rendering all items I am rendering only few items horizontally and vertically. Then on scroll based on mouse
The problem is that you are hooking your onmousewheel event on #foo but don't realize that #foo is only as big as the data it contain. If you make the following change (i.e. take #wrapper instead of #foo)
var listHold = document.getElementById('wrapper');
You'll notice that the value do get updated.