从多个Href获取多个值 [英] GET Multiple Values From Multiple Href

查看:46
本文介绍了从多个Href获取多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<a href="?cate=politics">Politics</a> ~ <a href="?cout=us">United States</a>

我不确定是否可以在PHP中实现这种功能,可能是JavaScript,但我对JS的了解并不多.

I'm not quiet sure this is possible in PHP, maybe JavaScript but I don't know much JS.

我想从多个 a href 链接中获取多个GET值.上面的代码.假设我单击"Politics",然后将"Politics"值添加到URL,然后单击"United States",我也尝试将United States的值添加到URL,但是在瞬间只是覆盖那里的那一个.

I want to get multiple GET values from multiple a href links. The code is above. Let's say I click on Politics, and then it'll add the Politics value to the URL, and then I'll click on United States, and I'm trying to add the value of United States to the URL too, but at the moment it's just overwriting the one that's there.

如果单击政治",它将添加?cate = politics ,然后,如果单击美国",它还将添加& cout = us .因此,它将类似于:?cate = politics& cout = us .

If I click on Politics it adds ?cate=politics, and then if I click United States it adds &cout=us as well. So it'll be something like: ?cate=politics&cout=us.

我试图在单击两个链接时都在URL中获得两个GET变量.如果有帮助,我正在构建一个将获取GET变量的过滤器.

I'm trying to get both GET variables in the URL when clicking both links. If it helps I'm building a filter that will grab the GET variables.

推荐答案

如果我了解您,这将是解决方案:

If I understood you, this would be the solution:

<a href="cate=politics" onclick="return addToUrl(this.href);">Politics</a> ~ 
<a href="cout=us" onclick="return addToUrl(this.href);>United States</a>

JavaScript:

Javascript:

<script>
function addToUrl(str){
   location.href = location.href + "?" + str;
   return false;
}
</script>

希望这会有所帮助.干杯

Hope this helps. Cheers

这篇关于从多个Href获取多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆