pagination working with javascript