表单容器输入值问题

单选按钮提供访问和撤销访问在 HTML 页面中。单击提供访问权限时,它将显示一些从用户那里获取值的选项,这在没有蚂蚁问题的情况下工作,与单击撤销访问按钮相同,它将显示一些从用户那里获取值的选项。但是这里的问题是撤消访问权限也从提供访问单选按钮中获取值。知道下面的代码有什么问题


<html>


<head>

  <script type="text/javascript">

    function empty() {

      var x;

      x = document.getElementById("qx").value;

      y = document.getElementById("pwd").value;

      if (x == "") {

        alert("QX number should not be null");

        return false;

      };

      if (y == "") {

        alert("Password should not be null");

        return false;

      };

    }

  </script>

  <style>

    .top {

      position: relative;

      background-color: #ffffff;

      height: 68px;

    }

    

    .top1 {

      top: 110px;

      left: 476px;

      position: fixed;

      background-color: #ffffff;

      height: 70px;

    }

  </style>

</head>


<body>

  <script type="text/javascript">

    function displayForm(c) {

      if (c.value == "1") {

        document.getElementById("provideContainer").style.visibility = 'visible';

        document.getElementById("revokeContainer").style.visibility = 'hidden';

      } else if (c.value == "2") {

        document.getElementById("provideContainer").style.visibility = 'hidden';

        document.getElementById("revokeContainer").style.visibility = 'visible';

      } else {}

    }

  </script>

  <center>

    <font color="green">

      <h2>Please Select the below option</h2>

    </font><br>

    <form>

      <input value="1" type="radio" name="formselector" onClick="displayForm(this)"></input>

      <font size="3" color="orange">Provide Access</font>

      <input value="2" type="radio" name="formselector" onClick="displayForm(this)"></input>

      <font size="3" color="orange">Revoke Access</font>

      </form>

    </div>

</body>


</html>



蝴蝶不菲
浏览 139回答 1
1回答

翻翻过去那场雪

如果您的意思是如果 qx 号码和密码不为空,则使用 Javascript 进行检查,这是因为您在 revoke 中分配输入并提供访问相同的 id 以进行检查。(id="qx" 和 id="pwd")这就是 id 的作用。它应该仅在此站点上存在一次。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript