我有一個頁面,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代碼,接收按鈕發送給它。
以上是我重新編輯的代碼,如果您在編碼上編輯,我將非常感激。
請修復您的代碼粘貼(縮進4空格或使用ctrl + k選項) – drudge 2010-10-28 18:52:34
另外,請爲您的問題添加一些標點符號和大寫字母。我很確定那裏肯定有不止一句話。 – kindall 2010-10-28 19:08:17