-2

I'm currently working on a online catalogue and need help with a specific feature. I have a page manageCards.xhtml which contains a table, which displays card information (this has been hard-coded). There is a button at the bottom of this page which takes them to a new page addNewCards.xhtml where they can fill in the relevant fields to register a new card.

My question is, is there a way I can transfer the values between these pages and populate a new instance of the same table back on the manageCards.xhtml page, but for the newly registered card? I'm relatively new to both JavaScript and jQuery but I'm sure there's a way I'm not familiar with yet.

Any help would be greatly appreciated

Many thanks

CH1ND1T
  • 11

1 Answers1

1

You can use localStorage.

When you click the button, before navigating, you can store the data in local storage so that it can be read in the new page.

function storeCardInfo(data) {
  localStorage.setItem('cardData', JSON.stringify(data));
}

Then on the second page, read that data from localStorage.

function getCardInfo() {
   var cardInfo = localStorage.getItem('cardData');
   return JSON.parse(cardInfo);
}
nixkuroi
  • 2,259
  • 1
  • 19
  • 25