【发布时间】:2010-10-28 18:50:28
【问题描述】:
我有一个页面,home.php。在页面上,我有 CSS 选项卡 tab1 和 tab2。标签在同一页面上,而不是不同的页面上。我希望每当我单击tab2 内容中的提交按钮时显示tab2 的内容,而不是带我回到tab1。如何使用 JavaScript 来实现这种行为?
<html>
<head>
<title>home</title>
</head>
<link href="SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<body>
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">Tab1</li>
<li class="TabbedPanelsTab" tabindex="0">Tab2</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent">
//this is where the content of the tab1 will be and i have another form in this content too
</div>
<div class="TabbedPanelsContent">
//this is where the content of the tab2 will be
<form action="home.php" method="post">
<?php
if (isset($_POST['submit'])) {
if(empty($_POST['boded']){
echo"Please do it again.";
}else{
$mgs = ($_POST['boded']);
//then insert to my database
}
?>
<textarea id="message" name="boded" rows="5" cols="40"></textarea>
<input type="submit" name="submit" value="Submit" />
//if i click this button(submit) in this content it should display tab2 content not tab1
</form>
</div>
</div>
</body>
</html>
我已经尝试了第一个人要求我做的事情;它可以工作,但是有一个问题:提交按钮没有发送到$_POST['submit'],是否因为我的按钮中的错误(<input type="submit" name="submit" value="Submit" onClick="show_content('div_2'); return false;"/>)我跌倒了我提到在tab2内容中我有一个PHP代码接收发送给它的按钮。
以上是我重新编辑的代码,如果您在make代码上进行编辑,我将不胜感激。
【问题讨论】:
-
请修正您的代码粘贴(缩进 4 个空格,或在所选内容上使用 ctrl+k)
-
另外,请在您的问题中添加一些标点符号和大写字母。我很确定里面肯定不止一句话。
标签: php javascript html css ajax