首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用(搜索文本框)查找复选框的文本?

如何使用(搜索文本框)查找复选框的文本?
EN

Stack Overflow用户
提问于 2017-06-02 02:17:29
回答 1查看 101关注 0票数 1

如何使用(搜索文本框)找到复选框的文本,在一个单词之后,将其放入文本框并单击enter,它将根据下面的代码显示该复选框。这样做的编码是什么?如果(f & g) {不起作用的话,我的复选框。它没有显示我所放的结果。为什么?有人能修好我的密码吗?

代码语言:javascript
复制
<!DOCTYPE html>
<style>
  body,
  h1 {
    font-family: "Montserrat", sans-serif
  }
  
  img {
    margin-bottom: -7px
  }
  
  input[type=text] {
    width: 130px;
    font-size: 14px;
    background-color: white;
    background-position: 10px 10px;
    background-repeat: no-repeat;
  }
  
  input[type=text]:focus {}
</style>

<body>

  <!-- Header -->
  <h3><b><label for="search">Search</label></b>
    <input id="search" type="text" name="search" placeholder="Search.." /></h3>

  <head>
    <script>
      function fungsi() {

        var a = document.getElementById("subSolving1").checked;
        var b = document.getElementById("subSolving2").checked;
        var c = document.getElementById("subSolving3").checked;

        var d = document.getElementById("subConclusion1").checked;
        var e = document.getElementById("subConclusion2").checked;

        var f = document.getElementById("subRepeated1").checked;
        var g = document.getElementById("subRepeated2").checked;

        if (c || d === true) {
          document.getElementById("Status").innerHTML = "Problem1";
        } else if (b || a || e) {
          document.getElementById("Status").innerHTML = "Problem2";
        } else if (f) {
          document.getElementById("Status").innerHTML = "Problem3";
        } else if (g) {
          document.getElementById("Status").innerHTML = "Problem4";
        } else if (f && g) {
          document.getElementById("Status").innerHTML = "Problem5";
        }
      }
    </script>
  </head>

  <body>

    <b>Origin:</b>

    <script type="text/javascript">
      function ShowHideDiv(Solving) {
        var subSolving = document.getElementById("subSolving");
        subSolving.style.display = Solving.checked ? "block" : "none";
      }
    </script>
    <label for="Solving"> <input type="checkbox" id="Solving" onclick="ShowHideDiv(this)" value="Solving"/>Solving</label>

    <script type="text/javascript">
      function ShowHideDiv2(Conclusion) {
        var subConclusion = document.getElementById("subConclusion");
        subConclusion.style.display = Conclusion.checked ? "block" : "none";
      }
    </script>
    <label for="Conclusion"> <input type="checkbox" id="Conclusion" onclick="ShowHideDiv2(this)" value="Conclusion"/>Conclusion</label>

    <script type="text/javascript">
      function ShowHideDiv3(Repeated) {
        var subRepeated = document.getElementById("subRepeated");
        subRepeated.style.display = Repeated.checked ? "block" : "none";
      }
    </script>
    <label for="Repeated"> <input type="checkbox" id="Repeated" onclick="ShowHideDiv3(this)" value="Repeated"/>
			Repeated</label>

    <div id="subSolving" style="display: none">
      <p><label> <input type="checkbox" id="subSolving1" onclick="fungsi()"/>subSolving1 
					</label></p>

      <p><label> <input type="checkbox" id="subSolving2" onclick="fungsi()"/>subSolving2</label></p>

      <p><label> <input type="checkbox" id="subSolving3" onclick="fungsi()"/>subSolving3 </label></p></div>

      <div id="subConclusion" style="display: none">

        <p><label> <input type="checkbox" id="subConclusion1" onclick="fungsi()"/>subConclusion</label></p>

        <p><label> <input type="checkbox" id="subConclusion2" onclick="fungsi()"/>subConclusion
					</label></p>
      </div>

      <div id="subRepeated" style="display: none">
        <p><label> <input type="checkbox" id="subRepeated1" onclick="fungsi()"/>subRepeated1</label></p>

        <p><label> <input type="checkbox" id="subRepeated2" onclick="fungsi()"/>subRepeated2
					</label></p>
      </div>

      <b><hr/><p id="Status"></p></b></header>

    </div>
    </div>
  </body>

EN

回答 1

Stack Overflow用户

发布于 2017-06-02 03:36:14

我建议您组织html代码、样式和脚本。避免内联编码,以防止混淆。使用外部脚本并将其引用到html代码.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44319817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档