应用后无法保留表的格式

时间:2018-05-22 21:14:28

标签: html html-table hidden

所以我有一个目前按原样运行的代码。

    <!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="Editorial">
<table>
    <tr>
        <th style="border-right:solid 1px"><p id="Editorial01"><font color="red"></th>
        <th style="border-right:solid 1px"><p id="Editorial02"><font color="red"></p><p id="Editorial03"><font color="red"></p></th>
        <th>Given</th>
    </tr>
    <tr>
        <th style="border-right:solid 1px">
            <table>
                <tr>
                    <th><p id="EditorialAD"></th>
                    <th></th>
                    <th><p id="EditorialBC"></th>
                </tr>
                <tr>
                    <th>---------</th>
                    <th>+</th>
                    <th>---------</th>
                </tr>
                <tr>
                    <th><p id="EditorialBD1"></th>
                    <th></th>
                    <th><p id="EditorialBD2"></th>
            </table>
        </th>
        <th style="border-right:solid 1px">
            <p>This will always make a common denominator</p>
            <p>but it will not always be the least common denominator</p>
        </th>
        <th>
            <p>Apply Common Denominators of B x D</p>
        </th>
</table>
</div>
<div id="Section_0">
    <p>Welcome to the Fraction Section of this program<font size=6></p>
    <p>We will be working on <font size=6></p>
    <p> <sup>A</sup>&frasl;<sub>B</sub> + <sup>C</sup>&frasl;<sub>D</sub><p><font size=6></p>
    <p></p>
    <p></p>
    <button onclick="Script0()" id="button1" size=6>Proceed</button><p></p>
    </div>
        <script>
            function Script0(){
                var x = document.getElementById("Section_0");
                    x.style.display = 'none';
                var x = document.getElementById("Section_1")
                    x.style.display = 'block'
            }
        </script>
<div id="Section_1" hidden>
    <p><font size=4></p>
    Please tell me what you are adding?<p>
    **Placement Matters**<p>
    <sup>A</sup>&frasl;<sub>B</sub> + <sup>C</sup>&frasl;<sub>D</sub><p>

<table>
    <tr>
        <th><input type="text" id="AbsoluteA" size=3 placeholder="A"></th>
        <th></th>
        <th><input type="text" id="AbsoluteC" size=3 placeholder="C"></th>
    </tr>
    <tr>
        <th>---------</th>
        <th>+</th>
        <th>---------</th>
    </tr>
    <tr>
        <th><input type="text" id="AbsoluteB" size=3 placeholder="B"></th>
        <th></th>
        <th><input type="text" id="AbsoluteD" size=3 placeholder="D"></th>
</table>
    <p></p>
    <p id="FAILEDHERE"></p>
        <button onclick="Script1()" id="button2">Proceed</button><p></p>
    </div>
        <script>
            function Script1(){
                var a = document.getElementById("AbsoluteA").value;
                var b = document.getElementById("AbsoluteB").value;
                var c = document.getElementById("AbsoluteC").value;
                var d = document.getElementById("AbsoluteD").value;
                if ((a == parseInt(a)) && (b == parseInt(b)) && (c == parseInt(c)) && (d == parseInt(d)) && (d != 0) && (b != 0)){
                    document.getElementById("Editorial01").innerHTML = ("So we have "+a+"/"+b+" + "+c+"/"+d);
                    document.getElementById("Editorial02").innerHTML = ("A="+a+" C="+c) 
                    document.getElementById("Editorial03").innerHTML = ("B="+b+" D="+d)
                    var x = document.getElementById("Section_1");
                        x.style.display = 'none';
                    var x = document.getElementById("Section_2")
                        x.style.display = 'block'
                    var x = document.getElementById("EditorialFirst")
                        x.style.display = 'block'               }
                else {
                    document.getElementById("FAILEDHERE").innerHTML = ("Please input valid values please")
                }
            }
        </script>

这是我的问题:我希望一次只能显示表格的某些部分,所以我想我可以为每个部分设置一个ID并隐藏它们。然而,当我揭示1它似乎很好。当我揭示第二个时,格式被搞砸了。

问题:如何在不破坏整体格式的情况下使用隐藏隐藏个人并揭示个人?

这是我想要它做的一个版本,但未能保持格式

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="Editorial">
<table>
    <tr id="EditorialFirst" hidden>
        <th style="border-right:solid 1px"><p id="Editorial01"><font color="red"></th>
        <th style="border-right:solid 1px"><p id="Editorial02"><font color="red"></p><p id="Editorial03"><font color="red"></p></th>
        <th>Given</th>
    </tr>
    <tr id="EditorialSecond" hidden>
        <th style="border-right:solid 1px">
            <table>
                <tr>
                    <th><p id="EditorialAD"></th>
                    <th></th>
                    <th><p id="EditorialBC"></th>
                </tr>
                <tr>
                    <th>---------</th>
                    <th>+</th>
                    <th>---------</th>
                </tr>
                <tr>
                    <th><p id="EditorialBD1"></th>
                    <th></th>
                    <th><p id="EditorialBD2"></th>
            </table>
        </th>
        <th style="border-right:solid 1px">
            <p>This will always make a common denominator</p>
            <p>but it will not always be the least common denominator</p>
        </th>
        <th>
            <p>Apply Common Denominators of B x D</p>
        </th>
</table>
</div>
<div id="Section_0">
    <p>Welcome to the Fraction Section of this program<font size=6></p>
    <p>We will be working on <font size=6></p>
    <p> <sup>A</sup>&frasl;<sub>B</sub> + <sup>C</sup>&frasl;<sub>D</sub><p><font size=6></p>
    <p></p>
    <p></p>
    <button onclick="Script0()" id="button1" size=6>Proceed</button><p></p>
    </div>
        <script>
            function Script0(){
                var x = document.getElementById("Section_0");
                    x.style.display = 'none';
                var x = document.getElementById("Section_1")
                    x.style.display = 'block'
            }
        </script>
<div id="Section_1" hidden>
    <p><font size=4></p>
    Please tell me what you are adding?<p>
    **Placement Matters**<p>
    <sup>A</sup>&frasl;<sub>B</sub> + <sup>C</sup>&frasl;<sub>D</sub><p>

<table>
    <tr>
        <th><input type="text" id="AbsoluteA" size=3 placeholder="A"></th>
        <th></th>
        <th><input type="text" id="AbsoluteC" size=3 placeholder="C"></th>
    </tr>
    <tr>
        <th>---------</th>
        <th>+</th>
        <th>---------</th>
    </tr>
    <tr>
        <th><input type="text" id="AbsoluteB" size=3 placeholder="B"></th>
        <th></th>
        <th><input type="text" id="AbsoluteD" size=3 placeholder="D"></th>
</table>
    <p></p>
    <p id="FAILEDHERE"></p>
        <button onclick="Script1()" id="button2">Proceed</button><p></p>
    </div>
        <script>
            function Script1(){
                var a = document.getElementById("AbsoluteA").value;
                var b = document.getElementById("AbsoluteB").value;
                var c = document.getElementById("AbsoluteC").value;
                var d = document.getElementById("AbsoluteD").value;
                if ((a == parseInt(a)) && (b == parseInt(b)) && (c == parseInt(c)) && (d == parseInt(d)) && (d != 0) && (b != 0)){
                    document.getElementById("Editorial01").innerHTML = ("So we have "+a+"/"+b+" + "+c+"/"+d);
                    document.getElementById("Editorial02").innerHTML = ("A="+a+" C="+c) 
                    document.getElementById("Editorial03").innerHTML = ("B="+b+" D="+d)
                    var x = document.getElementById("Section_1");
                        x.style.display = 'none';
                    var x = document.getElementById("Section_2")
                        x.style.display = 'block'
                    var x = document.getElementById("EditorialFirst")
                        x.style.display = 'block'               }
                else {
                    document.getElementById("FAILEDHERE").innerHTML = ("Please input valid values please")
                }
            }
        </script>
<div id="Section_2" hidden>
    As part of the Initial Math Phase<p>
    We are going to quote "cross multiply"<p>
    but it is actually just creating equivalent <p>
    fractions with a common denominator <p> 
    **THIS MAY NOT LEAST COMMON DENOMINATOR BUT IT IS A COMMON DENOMINATOR**<p>
    <p id="FAILED"><font size=4></p>
    <table>
    <tr>
        <th><input type="text" id="AbsoluteAD" size=3 placeholder="A x D"></th>
        <th></th>
        <th><input type="text" id="AbsoluteBC" size=3 placeholder="B x C"></th>
    </tr>
    <tr>
        <th>---------</th>
        <th>+</th>
        <th>---------</th>
    </tr>
    <tr>
        <th><input type="text" id="AbsoluteBD1" size=3 placeholder="B x D"></th>
        <th></th>
        <th><input type="text" id="AbsoluteBD2" size=3 placeholder="B x D"></th>
</table>
    <p></p>
    <p></p> 
    <button onclick="Script2()" id="button3">Proceed</button><p></p>
    </div>
        <script>
            function Script2(){
                var a = document.getElementById("AbsoluteA").value;
                var b = document.getElementById("AbsoluteB").value;
                var c = document.getElementById("AbsoluteC").value;
                var d = document.getElementById("AbsoluteD").value;
                var numone = a*d;
                var numtwo = b*c;
                var denone = b*d;
                var AD = document.getElementById("AbsoluteAD").value;
                var BC = document.getElementById("AbsoluteBC").value;
                var BD1 = document.getElementById("AbsoluteBD1").value;
                var BD2 = document.getElementById("AbsoluteBD2").value;
                if (BD1 == BD2 && (parseInt(BD1) == parseInt(BD2)) && (BD1 == denone)){
                    var BD = parseInt(BD1)
                }
                if ((numone == AD) && (numtwo == BC) && (denone == BD)) {
                    var x = document.getElementById("Section_2");
                        x.style.display = 'none';
                    var y = document.getElementById("Section_3")
                        y.style.display = 'block';
                    document.getElementById("EditorialAD").innerHTML = (+AD)
                    document.getElementById("EditorialBC").innerHTML = (+BC)
                    document.getElementById("EditorialBD1").innerHTML = (+BD2)
                    document.getElementById("EditorialBD2").innerHTML = (+BD2)
                    var x = document.getElementById("EditorialSecond")
                        x.style.display = 'block'   
                } else {
                    document.getElementById("FAILED").innerHTML = ("Try Again")
                }
            }
        </script>

0 个答案:

没有答案