It seems you’ll want to use some kind of server, or a form to get a value to assign it to a variable. Once it takes you to the new page you can simply pull the variable out of the server. Or store it in a session or a cookie.
solved How to put condition from another page into a button?