我正在尝试创建一个网页,该网页有一个显示不同文本的区域,具体取决于单击的链接。我已经看过if else代码,嵌入对象,点击命令。
这是我整理的一些基本代码。有人能告诉我我是走在正确的轨道上还是哪里出了问题吗。我也认为我需要使用AJAX,但我对此并不熟悉。
任何帮助都将不胜感激。
<table width="80%" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<div align="center">
<a href="#Step1" class="menuNav">
<strong>Step 1</strong>
</a>
</div>
</td>
<td>
<div align="center">
<a href="#Step2" class="menuNav">
<strong>Step 2</strong>
</a>
</div>
</td>
<td>
<div align="center">
<a href="#Step3" class="menuNav">
<strong>Step 3</strong>
</a>
</div>
</td>
</tr>
</table>
<br />
<object type="text/html" width="80" height="150" border="thin">
<?php
if( onclick = "#Step1" ) {
echo (i hope this work );
} else { }
?>
</object>
您的意思是为不同的链接显示不同的区域吗?以下是代码的样子:
<table width="80%" cellspacing="0" cellpadding="0" align="center">
<tr>
<?php
switch ($_GET['step']) {
case 1:
?>
<td>
<div align="center">
<a href="#Step1" class="menuNav">
<strong>Step 1</strong>
</a>
</div>
</td>
<?php
break;
case 2:
?>
<td>
<div align="center">
<a href="#Step2" class="menuNav">
<strong>Step 2</strong>
</a>
</div>
</td>
<?php
break;
case 3:
?>
<td>
<div align="center">
<a href="#Step3" class="menuNav">
<strong>Step 3</strong>
</a>
</div>
</td>
<?php
break;
}
</tr>
</table>
这是一种非常简单的方式来显示不同url的标记的单独部分。然后,您可以让用户转到不同的链接,以显示不同的块(/script.php?step=1等)