简体   繁体   English

如何在HTML上添加页码

[英]How do i add page numbers on html

How can I add page numbers to a quiz I am making, it needs to all be in the same file though? 如何将页码添加到我正在做的测验中,尽管它必须全部位于同一文件中? So, after the first x many questions have been answered, you click next, to go onto the next page after that you go onto the answers? 因此,在回答了前x个问题后,您单击下一步,然后再转到答案上,转到下一页? But all in the same code? 但是全部都在同一代码中吗? How can I do this? 我怎样才能做到这一点? I've tried looking on various websites to find this but I cannot see how! 我尝试在各种网站上查找此内容,但看不到如何! Thanks, Nick 谢谢,尼克

Code: 码:

<h1>Final Quiz for Lip building</h1>

    <form action="grade.php" method="post" id="quiz">

        <ol>

            <li>

                <h3>CSS Stands for...</h3>

                <div>
                    <input type="radio" name="question-1-answers" id="question-1-answers-A" value="A" />
                    <label for="question-1-answers-A">A) Computer Styled Sections </label>
                </div>

                <div>
                    <input type="radio" name="question-1-answers" id="question-1-answers-B" value="B" />
                    <label for="question-1-answers-B">B) Cascading Style Sheets</label>
                </div>

                <div>
                    <input type="radio" name="question-1-answers" id="question-1-answers-C" value="C" />
                    <label for="question-1-answers-C">C) Crazy Solid Shapes</label>
                </div>

                <div>
                    <input type="radio" name="question-1-answers" id="question-1-answers-D" value="D" />
                    <label for="question-1-answers-D">D) None of the above</label>
                </div>

            </li>

            <li>

                <h3>Internet Explorer 6 was released in...</h3>

                <div>
                    <input type="radio" name="question-2-answers" id="question-2-answers-A" value="A" />
                    <label for="question-2-answers-A">A) 2001</label>
                </div>

                <div>
                    <input type="radio" name="question-2-answers" id="question-2-answers-B" value="B" />
                    <label for="question-2-answers-B">B) 1998</label>
                </div>

                <div>
                    <input type="radio" name="question-2-answers" id="question-2-answers-C" value="C" />
                    <label for="question-2-answers-C">C) 2006</label>
                </div>

                <div>
                    <input type="radio" name="question-2-answers" id="question-2-answers-D" value="D" />
                    <label for="question-2-answers-D">D) 2003</label>
                </div>

            </li>

            <li>

                <h3>SEO Stand for...</h3>

                <div>
                    <input type="radio" name="question-3-answers" id="question-3-answers-A" value="A" />
                    <label for="question-3-answers-A">A) Secret Enterprise Organizations</label>
                </div>

                <div>
                    <input type="radio" name="question-3-answers" id="question-3-answers-B" value="B" />
                    <label for="question-3-answers-B">B) Special Endowment Opportunity</label>
                </div>

                <div>
                    <input type="radio" name="question-3-answers" id="question-3-answers-C" value="C" />
                    <label for="question-3-answers-C">C) Search Engine Optimization</label>
                </div>

                <div>
                    <input type="radio" name="question-3-answers" id="question-3-answers-D" value="D" />
                    <label for="question-3-answers-D">D) Seals End Olives</label>
                </div>

            </li>

            <li>

                <h3>A 404 Error...</h3>

                <div>
                    <input type="radio" name="question-4-answers" id="question-4-answers-A" value="A" />
                    <label for="question-4-answers-A">A) is an HTTP Status Code meaning Page Not Found</label>
                </div>

                <div>
                    <input type="radio" name="question-4-answers" id="question-4-answers-B" value="B" />
                    <label for="question-4-answers-B">B) is a good excuse for a clever design</label>
                </div>

                <div>
                    <input type="radio" name="question-4-answers" id="question-4-answers-C" value="C" />
                    <label for="question-4-answers-C">C) should be monitored for in web analytics</label>
                </div>

                <div>
                    <input type="radio" name="question-4-answers" id="question-4-answers-D" value="D" />
                    <label for="question-4-answers-D">D) All of the above</label>
                </div>

            </li>

            <li>

                <h3>Your favorite website is</h3>

                <div>
                    <input type="radio" name="question-5-answers" id="question-5-answers-A" value="A" />
                    <label for="question-5-answers-A">A) CSS-Tricks</label>
                </div>

                <div>
                    <input type="radio" name="question-5-answers" id="question-5-answers-B" value="B" />
                    <label for="question-5-answers-B">B) CSS-Tricks</label>
                </div>

                <div>
                    <input type="radio" name="question-5-answers" id="question-5-answers-C" value="C" />
                    <label for="question-5-answers-C">C) CSS-Tricks</label>
                </div>

                <div>
                    <input type="radio" name="question-5-answers" id="question-5-answers-D" value="D" />
                    <label for="question-5-answers-D">D) CSS-Tricks</label>
                </div>

            </li>

        </ol>

        <input type="submit" value="Submit Quiz" />

    </form>
and 

PHP: ` PHP:

    <h1>Final Quiz for Lip building</h1>

    <?php

        $answer1 = $_POST['question-1-answers'];
        $answer2 = $_POST['question-2-answers'];
        $answer3 = $_POST['question-3-answers'];
        $answer4 = $_POST['question-4-answers'];
        $answer5 = $_POST['question-5-answers'];

        $totalCorrect = 0;

        if ($answer1 == "B") { $totalCorrect++; }
        if ($answer2 == "A") { $totalCorrect++; }
        if ($answer3 == "C") { $totalCorrect++; }
        if ($answer4 == "D") { $totalCorrect++; }
        if ($answer5) { $totalCorrect++; }

        echo "<div id='results'>$totalCorrect / 5 correct</div>";

    ?>

</div>`

EDIT: THE NEXT CODE I ADDED WAS: 编辑:我添加的下一个代码是:

  <div>
                    <input type="radio" name="question-3-answers" id="question-3-answers-D" value="D" />
                    <label for="question-3-answers-D">D) Seals End Olives</label>
                </div>

            </li>
           <script>
        function getValue()
            {
                var x=document.getElementById("page_2");
                alert(x.innerHTML);
            }
       </script>

<body>

    <h1 id="page_2" onclick="getValue()">Click me to proceed!</h1>

</body>
        </div>
        </div>
        <div id="page_2">
        <div id="page-wrap">

            <li>

                <h3>A 404 Error...</h3>

Use specific <div> with id for every part & hide all other <div> except first part using css. 每个部分都使用具有特定ID的<div>并使用CSS隐藏除第一部分以外的所有其他<div> Then use javascript function for showing every part sequentially. 然后使用javascript函数依次显示每个部分。 When showing 2nd part hide all other part using getElementById , do it all other part & store your result in a static variable, increase it in every part sequentially, hope it will work. 当显示第二部分时,请使用getElementById隐藏其他所有部分,将其他所有部分都保存起来并将结果存储在静态变量中,依次增加每个部分中的部分,希望它可以工作。 check this code - 检查此代码-

 <!DOCTYPE html> <html> <head> <title>TODO supply a title</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> #test2{display:none;} #test3{display:none;} </style> <script> function test1(){ document.getElementById('test2').style.display = 'block'; document.getElementById('test1').style.display = 'none'; } </script> </head> <body> <div id="test1" onclick='test1();'>testing1</div> <div id="test2">testing2</div> <div id="test3">testing3</div> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM