猿问

在Bootstrap中的nav-tabs下执行完结果如何不跳回预设tab?

小弟是个新手想练习写个单位换算的程序练手,感觉大概像这样:
1.公制轉英制

2.英制轉公制

https://img4.mukewang.com/5c8f6a7600011ab208000214.jpg

目前计算都没问题,但有个问题是在英制转公制里执行计算后,画面会跳回公制转英制的预设画面,需要再多点击一次英制转公制的标签后,才能看到执行的结果,如下图:
https://img.mukewang.com/5c8f6a780001fffb08000214.jpg

原碼如下:

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="tabbable" id="tabs-84805">
                <ul class="nav nav-tabs">
                    <li class="active">
                        <a href="#panel-26382" data-toggle="tab">公制轉英制</a>
                    </li>
                    <li>
                        <a href="#panel-398503" data-toggle="tab">英制轉公制</a>
                    </li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="panel-26382">
                                    <div class="row">
                                        <div class="col-md-12">
                                        <h4><b>長度換算</b>&nbsp;&nbsp;<?php for ($i = 1; $i <= 145; $i++){echo '&nbsp;';}?><span class="label label-default"">請輸入公分</span></h4><hr>
                                        </div>

                                <!--控制左邊輸入欄-->
                                        <div class="col-md-6">
                                            <form action="" method="POST" accept-charset="utf-8">
                                            長:<input type="text" name="lencm">&nbsp;&nbsp;&nbsp;公分<br><br>
                                            寬:<input type="text" name="widthcm">&nbsp;&nbsp;&nbsp;公分<br><br>
                                            高:<input type="text" name="heighcm">&nbsp;&nbsp;&nbsp;公分<?php for ($i = 1; $i <= 50; $i++){echo '&nbsp;';}?>
                                            <button type="submit" name="sub" class="btn btn-warning">開始計算</button>
                                            </form>
                                        </div>
                                <!--控制右邊結果輸出欄-->
                                        <div class="col-md-6">
                                                    長:<input type="text" name="lenin" style="background-color:#dddddd" value="<?php
                                                if ( isset($_POST['sub'])){
                                                    if ( is_numeric($_POST['lencm'])){
                                                        $i=$_POST['lencm'];$lenin=$i/2.54;
                                                        echo round($lenin,2);
                                                    } else{ echo "請輸入數字";}
                                                }
                                            ?>" readonly="readonly">&nbsp;&nbsp;&nbsp;英吋<br><br>
                                                    寬:<input type="text" name="widthin" style="background-color:#dddddd" value="<?php
                                                if ( isset($_POST['sub'])){
                                                    if ( is_numeric($_POST['widthcm'])){
                                                        $w=$_POST['widthcm'];$widthin=$w/2.54;
                                                        echo round($widthin,2);
                                                    } else{ echo "請輸入數字";}
                                                }
                                            ?>" readonly="readonly">&nbsp;&nbsp;&nbsp;英吋<br><br>
                                                    高:<input type="text" name="heighin" style="background-color:#dddddd" value="<?php
                                                if ( isset($_POST['sub'])){
                                                    if ( is_numeric($_POST['heighcm'])){
                                                        $h=$_POST['heighcm'];$heighin=$h/2.54;
                                                        echo round($heighin,2);
                                                    } else{ echo "請輸入數字";}
                                                }
                                            ?>" readonly="readonly">&nbsp;&nbsp;&nbsp;英吋<br><br>
                                        </div>
                                    </div>
                    </div>
                <div class="tab-pane" id="panel-398503">
                    <div class="row">
                                        <div class="col-md-12">
                                        <h4><b>長度換算</b>&nbsp;&nbsp;<?php for ($i = 1; $i <= 145; $i++){echo '&nbsp;';}?><span class="label label-default"">請輸入英吋</span></h4><hr>
                                        </div>

                                <!--控制左邊輸入欄-->
                                        <div class="col-md-6">
                                            <form action="" method="POST" accept-charset="utf-8">
                                            長:<input type="text" name="lenin">&nbsp;&nbsp;&nbsp;英吋<br><br>
                                            寬:<input type="text" name="widthin">&nbsp;&nbsp;&nbsp;英吋<br><br>
                                            高:<input type="text" name="heighin">&nbsp;&nbsp;&nbsp;英吋<?php for ($i = 1; $i <= 50; $i++){echo '&nbsp;';}?>
                                            <button type="submit" name="sub1" class="btn btn-warning">開始計算</button>
                                            </form>
                                        </div>
                                <!--控制右邊結果輸出欄-->
                                        <div class="col-md-6">
                                                    長:<input type="text" name="lenin" style="background-color:#dddddd" value="<?php
                                                if ( isset($_POST['sub1'])){
                                                    if ( is_numeric($_POST['lenin'])){
                                                        $i1=$_POST['lenin'];$lencm=$i1*2.54;
                                                        echo round($lencm,2);
                                                    } else{ echo "請輸入數字";}
                                                }
                                            ?>" readonly="readonly">&nbsp;&nbsp;&nbsp;公分<br><br>
                                                    寬:<input type="text" name="widthcm" style="background-color:#dddddd" value="<?php
                                                if ( isset($_POST['sub1'])){
                                                    if ( is_numeric($_POST['widthin'])){
                                                        $w1=$_POST['widthin'];$widthcm=$w1*2.54;
                                                        echo round($widthcm,2);
                                                    } else{ echo "請輸入數字";}
                                                }
                                            ?>" readonly="readonly">&nbsp;&nbsp;&nbsp;公分<br><br>
                                                    高:<input type="text" name="heighcm" style="background-color:#dddddd" value="<?php
                                                if ( isset($_POST['sub1'])){
                                                    if ( is_numeric($_POST['heighin'])){
                                                        $h1=$_POST['heighin'];$heighcm=$h1*2.54;
                                                        echo round($heighcm,2);
                                                    } else{ echo "請輸入數字";}
                                                }
                                            ?>" readonly="readonly">&nbsp;&nbsp;&nbsp;公分<br><br>
                                        </div>
                                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>`

我想要最后的结果是在英制转公制里执行完后就直接停留在该页标签里,而不要再多点击一次该标签才能看到结果,查了一下资料好像是跟ACTIVE有关,但试了几次都没辨法,请问该怎么修改呢?谢谢

一只萌萌小番薯
浏览 963回答 1
1回答
随时随地看视频慕课网APP
我要回答