基于php标头的javascript切换获取值?
我有两个显示/隐藏 div 部分的链接(在每个 div 部分中我运行 sql 查询),
<li><a href="javascript:toggle('subscription')"><b>Subscription Details</b></a></li>
<li><a href="javascript:toggle('stusearch')"><b>Personal Information</b></a></li>
同时将查询结果返回到原始页面,我将通过 url 传递参数,并希望在 usrsecuredpage.php 上接收它们,其中包含我想根据我得到的标题显示/隐藏各种javascript切换。
例如我得到
header('Location: usrsecuredpage.php?id=personalinfo');
我想切换“stusearch”
如果标题是
header('Location: usrsecuredpage.php?id=subscriptioninfo');
然后切换“订阅”
请帮忙
I have two links which show / hide div sections (inside each div section i am running sql queries)
<li><a href="javascript:toggle('subscription')"><b>Subscription Details</b></a></li>
<li><a href="javascript:toggle('stusearch')"><b>Personal Information</b></a></li>
while getting query results back to original page, i would be passing parameters via url and would like to receive them on usrsecuredpage.php which contains the various javascript toggles which i would like to show/hide based on the header i get.
for example is i get
header('Location: usrsecuredpage.php?id=personalinfo');
i would like to toggle "stusearch"
if the header is
header('Location: usrsecuredpage.php?id=subscriptioninfo');
then toggle "subscription"
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它不是那样工作的。 PHP 代码在服务器上运行。 JavaScript 在客户端上运行。
如果您想做的只是一个简单的重定向,请使用 Javascript 来完成。
It doesn't work like that. The PHP code runs on the server. Javascript runs on the client.
If all you want to do is a simple redirect, do it with Javascript.
我相信你想
将 html 更改为
I believe you want
then change the html to
在 php 标头中发送标头...如果您正在访问 usrsecuredpage.php 并想知道 id 是什么,您需要使用 $_GET 超全局。
更新:
如果我理解正确的话,您希望页面上的 div 无论如何,并且根据传递给 php 脚本的 id 显示适当的 div。如果是这样,您可以在页面底部执行此操作。
这是一个有点丑陋的解决方案,但它有效。
In php header sends headers... If you are visiting usrsecuredpage.php and want to know what id is you need to use the $_GET superglobal.
Update:
If I'm understanding you correctly, you want the divs on the page regardless and the appropriate div to show up based on the id passed to the php script. If so, you could do this at the bottom of your page.
It's kinda an ugly solution but it works.