HTML/CGI: When linking, append variable/value pair instead of replacing?
If on page foo.php I have a link with <a href=?bar=baz>Click</a>
, that link will bring a user to foo.php?bar=baz. But what if the user is already on foo.php?bar=baz, and I want to link them to foo.php?bar=baz&qux=derp, is there a way to express this in the href attribute of the a tag? If my tag is <a href=?qux=derp>Click</a>
then the user is directed to foo.php?qux=derp instead of foo.php?bar=baz&qux=derp.
Thanks!
I tagged this as CGI because I think the ?bar=baz part of the UR开发者_JAVA技巧L is more related towards that, but please correct me if I am wrong.
There is no way to do so. You will need to parse the current URL and add the new parameter appropriately.
精彩评论