-1

I would like to show the array item in one by one fashion with next & previous similar to slideshow. When my page loads i am storing data from my db in this way->## Heading ## var sampleTags = <?php echo json_encode($query); ?>;

i.e

var sampleTags = ["quote 1", "quote 2", "quote 3","quote 4", "quote 5", "quote 6", "quote 7"];

So, now i would like to show one by one item from this ( sampleTags) array , with previous and next link.

For this i tried:

main point for next is:

curIdx = (curIdx+1) / max;

and previous:

 curIdx = (curIdx+max-1) / max;

But i don'nt know why its not working

here is link Fiddle Please help me to solve this issue.

Dan
  • 2,086
  • 11
  • 71
  • 137
  • Show your code that you try – Dineshkani May 16 '13 at 13:12
  • @Dineshkani sir, i know javascript little bit only. I don't know how to take a item from my above list using javascript/jquery code. Currently, in my mind nothing javascript code is coming to implement this. That's the reason , i did not shown any code in my above question – Dan May 16 '13 at 13:16
  • 1
    Refer this http://stackoverflow.com/questions/3010840/loop-through-array-in-javascript – Dineshkani May 16 '13 at 13:20

1 Answers1

2

here is example that could help you.

http://jsfiddle.net/ndFGL/

main point for next is:

 curIdx = (curIdx+1) % max;

and previous:

 curIdx = (curIdx+max-1) % max;
Davor Mlinaric
  • 1,989
  • 1
  • 19
  • 26
  • Actually its easy. I learn a new thing from your side. Thank you for your support. – Dan May 16 '13 at 15:07