0

I've got a little 5 image display thing with a button to see the next 5.

if say someone hits the next button and there are only 2 more images to show, the next two are shown but after that the JavaScript crashes

Is there a way I can check to see if the next item I'm trying to get exists or not

here is what I'm using to get the item from the DB and "genre_count" is my image counter for displaying image 1,2,3...

......
film_list = tx.executeSql('SELECT * FROM mydb WHERE genre = "Drama"');
.....
...
film_item = film_list.rows.item(genre_count).image   

return film_item

Can I do something like this pseudo code

if (film_list.rows.item(genre_count).image === empty)
      film_item=""
  else   
    film_item = film_list.rows.item(genre_count).image            

1 Answer 1

2

There's a variable film_list.rows.length that tells you the number of rows that were returned.

Just compare against that to know when to stop returning new items.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.