猿问

如何将单选按钮与输入文本字段绑定?

这是员工的注册表单。如果员工是临时员工或永久员工,则必须签入单选按钮。如果是临时的,他应该填写输入的合同编号,如果是永久的,则应填写雇用日期。如何将单选按钮与输入绑定,以便他不能“交叉完成”,例如,如果他是临时的,请填写招聘日期。我想让他只有在按下特定的单选按钮时才能填写每个输入。


代码:


<?php include 'dbconfig.php';?>

<?php header('Content-Type: text/html; charset=utf-8');?>

<!DOCTYPE HTML PUCLIC "-//W3C//DTDHTML

4.0 Transitional//EN"><HTML>

  <HEAD>

      <link rel="stylesheet" type="text/css" href="logintest.css">

      <meta http-equiv="content-type" content="text/html; charset=UTF-8">

  </HEAD>

  <button class="btn" TYPE="submit" name="goback" onclick="window.location.href='login.php'">Go Back </button>


      <?php

      error_reporting(E_ALL); ini_set('display_errors', 1);

      if(isset($_POST['submit']))

      {

        $sql = "INSERT INTO employee (empID,EFirst,ELast,username, passcode)

        VALUES ('".$_POST["empID"]."','".$_POST["EFirst"]."','".$_POST["ELast"]."','".$_POST["username"]."','".$_POST["passcode"]."')";


        $result = mysqli_query($conn,$sql);

        $answer=$_POST['kind'];

        if($answer='permament'){

          $sql1 = "INSERT INTO permament_employee (empID,Hiring_Date) VALUES ('".$_POST["empID"]."','".$_POST["date"]."')";

          $result1 = mysqli_query($conn,$sql1);

        }


        if ($answer='temporary'){

          $sql2= "INSERT INTO temporary_employee(empID) VALUES ('".$_POST["empID"]."')";

          $result2 = mysqli_query($conn,$sql2);

        }

        echo "<script> location.replace('login.php') </script>";

      }



慕田峪7331174
浏览 160回答 2
2回答

不负相思意

你需要javascript。您必须在单选按钮上绑定“更改”事件,并根据单选按钮选择的值设置输入的可见性。
随时随地看视频慕课网APP
我要回答