18910140161

html-通过复选框css+PHP-Stack Overflow更改header的文本样式

顺晟科技

2022-10-19 12:02:46

144

我有创建网页的任务。其中一个要点是能够通过复选框更改文本的样式。Web编程不是我的主要领域(我主要使用C#)。我不知道如何通过PHP来实现,因为我们最近已经开始学习。

有我的PHP代码。

    <?php
$firstName = "Yaroslav";
$lastName = "Yatsyk";
$studentID = "101343887";
$checks = [];

$courses = array("COMP1230"=>"Advanced Web Programming", "COMP2129" => "Advanced Object-Oriented Programming", "COMP2130" => "Application Development using Java",
"COMP2138" => "Advanced Database Development","COMP2147" => "System Analysis, Design And Testing", "GSCI1003" => "Statistics");
?>

<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Assignment 1</title>
        <meta name="description" content="Sending data by GET/POST method">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="author" content="Yaroslav Yatsyk">
        <link rel="stylesheet" href="101343887.css">
    </head>
    <body>
        <h1>
            <?php
            echo $firstName . " " . $lastName . " - " . $studentID;
            ?>
        </h1>
        <form action="101343887.php" action="POST">
    <section id="textFiled">
        Name: <input type="text" value="<?php echo $firstName?> " name="name" required>
        <br><br>
        Surname: <input type="text" value="<?php echo $lastName?>" name="surname" required>
        <br><br>
        Student ID: <input type="text" value="<?php echo $studentID?>" name="id" required>
        <br><br>

        Class: <input list = "classes" name="classes" id="classes" required>
        <datalist id="classes">
          <?php
            foreach($courses as $key=>$value){
                echo "<option>".$key."</option>"."<br />";
              }
          ?>
        </datalist>
    </section>
    <br>
    <section id="checkBoxes">
              <input type="checkbox" name="check[]" id="Strong" value="strong">
              <label for="Strong">Strong</label>

              <br><br>

              <input type="checkbox" name="check[]" id="Underline" value="underline">
              <label for="Underline">Underline</label>

              <br><br>

              <input type="checkbox" name="check[]" id="Uppercase" value="uppercase">
              <label for="Uppercase">Uppercase</label>
    </section>
<br><br>
    <section id="radios">
    <input type="radio" name="12ptx" id="12ptx" value="12pt">
              <label for="12ptx">12pt</label>

              <br><br>

              <input type="radio" name="18ptx" id="18ptx" value="18pt">
              <label for="18ptx">18pt</label>

              <br><br>

              <input type="radio" name="24ptx" id="24ptx" value="24pt">
              <label for="24ptx">24pt</label>
    </section>

    <br>
    <input type="submit" value="Submit">
        </form>

        <section id="output" style="height: 150px; width: 150px;">
              <h2>

        <?php


if(filter_input(INPUT_POST,'name',FILTER_SANITIZE_STRING) && filter_input(INPUT_POST,'surname',FILTER_SANITIZE_STRING) && (
    filter_input(INPUT_POST,'id',FILTER_SANITIZE_STRING)
)) 
    {
    $firstName = $_POST['name'];
    $lastName = $_POST['surname'];
    $studentID = $_POST['id'];   

    if(isset($_POST['check']) && !empty($_POST['check'])) {
        $checks = $_POST['check'];

        // Add code
       
    }

    
    }


echo $firstName . " " . $lastName . " " . $studentID;

        ?>
</h2>
        
        </section>

        <div>
            <?php
                    if(isset($_POST["classes"])) {
                    $key = $_POST["classes"];
                    }
                    echo $courses[$key];
                
            ?>
        </div>

        <?php

            echo "<hr>";
            echo show_source("101343887.php");
        ?>
        <script src=https://my.gblearn.com/js/loadscript.js></script>
    </body>
</html>

有我的CSS代码

    <?php
$firstName = "Yaroslav";
$lastName = "Yatsyk";
$studentID = "101343887";
$checks = [];

$courses = array("COMP1230"=>"Advanced Web Programming", "COMP2129" => "Advanced Object-Oriented Programming", "COMP2130" => "Application Development using Java",
"COMP2138" => "Advanced Database Development","COMP2147" => "System Analysis, Design And Testing", "GSCI1003" => "Statistics");
?>

<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Assignment 1</title>
        <meta name="description" content="Sending data by GET/POST method">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="author" content="Yaroslav Yatsyk">
        <link rel="stylesheet" href="101343887.css">
    </head>
    <body>
        <h1>
            <?php
            echo $firstName . " " . $lastName . " - " . $studentID;
            ?>
        </h1>
        <form action="101343887.php" action="POST">
    <section id="textFiled">
        Name: <input type="text" value="<?php echo $firstName?> " name="name" required>
        <br><br>
        Surname: <input type="text" value="<?php echo $lastName?>" name="surname" required>
        <br><br>
        Student ID: <input type="text" value="<?php echo $studentID?>" name="id" required>
        <br><br>

        Class: <input list = "classes" name="classes" id="classes" required>
        <datalist id="classes">
          <?php
            foreach($courses as $key=>$value){
                echo "<option>".$key."</option>"."<br />";
              }
          ?>
        </datalist>
    </section>
    <br>
    <section id="checkBoxes">
              <input type="checkbox" name="check[]" id="Strong" value="strong">
              <label for="Strong">Strong</label>

              <br><br>

              <input type="checkbox" name="check[]" id="Underline" value="underline">
              <label for="Underline">Underline</label>

              <br><br>

              <input type="checkbox" name="check[]" id="Uppercase" value="uppercase">
              <label for="Uppercase">Uppercase</label>
    </section>
<br><br>
    <section id="radios">
    <input type="radio" name="12ptx" id="12ptx" value="12pt">
              <label for="12ptx">12pt</label>

              <br><br>

              <input type="radio" name="18ptx" id="18ptx" value="18pt">
              <label for="18ptx">18pt</label>

              <br><br>

              <input type="radio" name="24ptx" id="24ptx" value="24pt">
              <label for="24ptx">24pt</label>
    </section>

    <br>
    <input type="submit" value="Submit">
        </form>

        <section id="output" style="height: 150px; width: 150px;">
              <h2>

        <?php


if(filter_input(INPUT_POST,'name',FILTER_SANITIZE_STRING) && filter_input(INPUT_POST,'surname',FILTER_SANITIZE_STRING) && (
    filter_input(INPUT_POST,'id',FILTER_SANITIZE_STRING)
)) 
    {
    $firstName = $_POST['name'];
    $lastName = $_POST['surname'];
    $studentID = $_POST['id'];   

    if(isset($_POST['check']) && !empty($_POST['check'])) {
        $checks = $_POST['check'];

        // Add code
       
    }

    
    }


echo $firstName . " " . $lastName . " " . $studentID;

        ?>
</h2>
        
        </section>

        <div>
            <?php
                    if(isset($_POST["classes"])) {
                    $key = $_POST["classes"];
                    }
                    echo $courses[$key];
                
            ?>
        </div>

        <?php

            echo "<hr>";
            echo show_source("101343887.php");
        ?>
        <script src=https://my.gblearn.com/js/loadscript.js></script>
    </body>
</html>

请不要有毒,或者不要把分数减,因为我刚开始在大学学习编程,并不是所有的事情都是可以理解的。我愿意变得更好,但我需要专业的协助来接近它。 谢谢


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航