So what I'm trying to is pretty complicated. I have a page with lots of buttons. This page is linked to a PHP file (that is responsible for the functionality of the page) and is also linked to a Javascript file (that handles other interactivity).
Each button is in its own section. When the user clicks on a button, it should get the text of a h2 tag within that particular section and store it in a variable.
I was able to do this with Javascript. Now what I want to do is, store that variable in my external PHP file, so that when the user navigates to a new page, the PHP file will still have that variable and it will be used to populate sections of the page that the user has just navigated too.
Essentially I have a list of items. When the user clicks on one item, they get directed to a page and the page details out the item they clicked on.
How do I do this? I seems very difficult to do because every time new page is loaded, both the script files refresh and pretty much forget everything that happened in the page before. All the variables get reassigned with their initial values.
I've heard of AJAX but what is the best way of doing this with just my current setup? How do I transfer that Javascript variable into my PHP file and make it stay there so that its stored for future use after navigating to new pages?