Reputation: 3965
I have a webpage that has several links that link to the same page, but depending on the link the user clicks I need to pass different info to that other page. I know how to do this in PHP through the URL and using $_GET[] but I am unsure how to do it using only javascript/jquery and html. Any idea? Thanks.
Upvotes: 2
Views: 4319
Reputation: 1502
You can attach a query string to the link, just as you would to use $_GET with PHP, but retrieve the query string on the target page using JavaScript, as explained here: How can I get query string values in JavaScript?
Edit: I've looked some more at the page to which I linked. There's a lot of very general code there, but if you use an = sign and only one parameter, you can split off the parameter with a JavaScript split:
<a href="target.html?from=A">Came from A</a>
target.html's 'location.search' will contain "?from=A" and a simple split will do it.
Upvotes: 2