• 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
  On 12/05/2016 at 23:07, 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.

Expand  

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.
  • Posts

    • Who goofed? I got to know. Wiki lists the internet speed of Singapore at 336.45 per Ookla, which would put them second behind Lyons France with the world's fastest median internet speed.
    • I'm really happy that you're looking to apply for a role in writing articles for Neowin. We could do with more, regardless, so everyone is happy and has a story to read when ever they login to the site. https://www.neowin.net/contact/apply I look forward to reading what you have to say in the near future in one of the published articles here on Neowin. You can do it. You got this.
    • Uranus releases about 15% more energy than it receives from the Sun, according to two new papers published in the journal Monthly Notices of the Royal Astronomical Society and the journal Geophysical Research Letters. The amount of heat a planet exudes could be an indication of its age: the less heat released relative to the heat absorbed from the Sun, the older the planet is. Uranus stood out from the other planets because it appeared to give off as much heat as it received, implying it had none of its own. This puzzled scientists. Some hypothesized that perhaps the planet is much older than all the others and has cooled off completely. Others proposed that a giant collision — the same one that may have knocked the planet on its side—blasted out all of Uranus’ heat. But none of these hypotheses satisfied scientists, motivating them to solve Uranus’ cold case. https://www.sci.news/space/warmer-uranus-14079.html  
    • The reality is that it's much, much cheaper to have a single code base than rewrite and maintain everything in native frameworks for each platform. It's just sad that the most reliable technology stack for it is so heavy on resources (literally 3 times the RAM, according to the screenshots).
    • Trump Logic:  If people are talking about football team names... they won't be talking about Epstein! 🤣
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      495
    2. 2
      Michael Scrip
      203
    3. 3
      ATLien_0
      197
    4. 4
      Xenon
      136
    5. 5
      +FloatingFatMan
      116
  • Tell a friend

    Love Neowin? Tell a friend!