I have a ID (1) of a record in the database and each time when I click the “NEXT” button, I wish to increment the ID into 2 and retrieve the next data. I store the ID into the sessionStorage.ID and later when I retrieve it and
sessionStorage.ID =sessionStorage.ID +1
The sessionStorage should be equal to 2 but it display as “11”. How can I resolve this?
Try this:
When you store the ID in sessionStorage, it gets saved as a string, so the
+sign concatenates the number instead of adding it.