在 PHP 中选项卡? [英] Tabbing in PHP?

查看:39
本文介绍了在 PHP 中选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有这些标签

装备 |税|平衡 |债务|基金 |ETF |镀金......

Equ | Tax | Balanced | Debt | Funds | ETF | Gilt .......

然后在这些选项卡下方有空间.当用户单击这些选项卡时,必须在该空间中显示与这些选项卡相对应的数据,而不会更改页面的 url.就像我单击 Equ 时一样,它的数据将显示在该空间中,如果我单击税则其数据将显示在相同的空间中,就像它覆盖了以前的数据一样.必须显示的数据是使用 php 计算的.现在使用 php 或 javascript 最简单的方法是什么???

and then there's space below these tabs. When user clicks on these tabs then a data corresponding to these tabs has to be displayed in that space without changing the url of the page.Like when i click Equ then its data will be displayed in that space ,if i click tax then its data will be displayed in that same space as if it has overwritten the previous data.The data that has to e shown is calculated using php. Now what is the easiest way to do so using php or javascript ???

这里有一些编码帮助将不胜感激.

some coding help would be appreciated here .

看到我知道这可以使用 javascript 来完成,但必须显示的数据在 php 变量中.现在如何将 php 变量分配给 javascript????

see i know this can be done using javascript but the data that has to be shown is in php variable .Now how to assign a php variable to javascript????

<script type="text/javascript">
function showhide(ref)
{
    document.getElementById('mf').innerHTML= HERE I WANT A PHP VARIABLE;
}
</script>

如何在 onclick 事件中发送我的 pfp 变量,以便它们可以在函数中使用???

how can i send my pfp variables in onclick event so that they can be used in the function???

推荐答案

您可以使用 CSS 或/和 Javascript 来帮助您解决问题.

You may use CSS or/and Javascript to help you do the trick.

仅使用 CSS 的选项卡示例:

Example of tabs using CSS only:

http://edeverett.co.uk/experiments/css_only_tabs.html

使用 Javascript 的选项卡示例:

Example of tabs using Javascript:

http://jqueryui.com/demos/tabs/

编辑作为对您的编辑的回复:

Edit As reply to your edit:

我知道这可以使用 javascript 完成,但必须显示的数据在 php 变量中.现在如何将 php 变量分配给 javascript ????

see i know this can be done using javascript but the data that has to be shown is in php variable .Now how to assign a php variable to javascript????

要在服务器端同步执行所有操作,您可以将计算结果注入到您的 javascript 中:

To perform everything on server-side synchronously, you can inject calculated result into your javascript:

function showhide(ref)
{
    document.getElementById('mf').innerHTML= '<?php echo $variable; ?>';
}

更好的做法是使用 AJAX.

A better practise would be to use AJAX.

这篇关于在 PHP 中选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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