为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
慕田峪7331174 2021-07-06 14:48:52
这是员工的注册表单。如果员工是临时员工或永久员工,则必须签入单选按钮。如果是临时的,他应该填写输入的合同编号,如果是永久的,则应填写雇用日期。如何将单选按钮与输入绑定,以便他不能“交叉完成”,例如,如果他是临时的,请填写招聘日期。我想让他只有在按下特定的单选按钮时才能填写每个输入。代码:<?php include 'dbconfig.php';?><?php header('Content-Type: text/html; charset=utf-8');?><!DOCTYPE HTML PUCLIC "-//W3C//DTDHTML4.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>";      }
查看完整描述

2 回答

?
不负相思意

TA贡献1777条经验 获得超10个赞

你需要javascript。您必须在单选按钮上绑定“更改”事件,并根据单选按钮选择的值设置输入的可见性。


查看完整回答
反对 回复 2021-07-09
  • 2 回答
  • 0 关注
  • 155 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信