• 0

JSON gallery issue with 2-digits id's


Question

Is any JSON gurus around? I use JSON library for my website gallery pages and everything up to thumbnails #9 works great. The problem starts when I click on thumbnail #10 (4-th row the first image from the left). When I click on it, it supposed to open the block with bigger image and additional text but it does not show anything, same for the thumbnail #20. If user clicks on thumbnail #11, it will show big image and text that correspond to thumbnails #1. My guess is  - JavaScript doesn't read 2 digits and reads only the one from right only: "10 "reads like  "0"; "11", "21" reads like "1".

Anyone can point me how to fix it in my code? I would appreciate any advice or help.

For each page I have group of files  - php (http://iskpublishing.com/fine-art/gallery-still-life.php), which works as an html and 2 files with javaScript coding (http://iskpublishing.com/fine-art/js/still-life-function.js  http://iskpublishing.com/fine-art/json/still-life.json )

 

Thank you.

2 answers to this question

Recommended Posts

  • 0
22 minutes ago, Yuliya said:

Is any JSON gurus around? I use JSON library for my website gallery pages and everything up to thumbnails #9 works great. The problem starts when I click on thumbnail #10 (4-th row the first image from the left). When I click on it, it supposed to open the block with bigger image and additional text but it does not show anything, same for the thumbnail #20. If user clicks on thumbnail #11, it will show big image and text that correspond to thumbnails #1. My guess is  - JavaScript doesn't read 2 digits and reads only the one from right only: "10 "reads like  "0"; "11", "21" reads like "1".

Anyone can point me how to fix it in my code? I would appreciate any advice or help.

For each page I have group of files  - php (http://iskpublishing.com/fine-art/gallery-still-life.php), which works as an html and 2 files with javaScript coding (http://iskpublishing.com/fine-art/js/still-life-function.js  http://iskpublishing.com/fine-art/json/still-life.json )

 

Thank you.

Line 26 of your script:

 

targetNumber = nextParent.id.slice(-1);

 

You're only getting the last digit of the id, so "box10".slice(-1) is returning 0.

 

A quick fix would be to call it like this:

 

 

	nextParent.id.slice(3)
	

That will return everything after "box".

This topic is now closed to further replies.