vendredi 19 juin 2020

JS: How to apply checkbox to search() function

document.write("<br>DataFieldNum : "+Object.keys(cultrans.DESCRIPTION).length+", ");
document.write(”RecordNum : "+Object.keys(cultrans.DATA).length, " <br>");
document.write("<hr>");

</script>
   <form>
   <fieldset>
   SearchF: 
   <input type = "checkbox" value="trafinfo"> trafinfo
   <input type = "checkbox" value="traftype"> traftype
   <input type = "checkbox" value="fac_name"> fac_name
   <input type = "checkbox" value="traftype_nm"> traftype_nm
   <input type = "checkbox" value="fac_code"> fac_code
   </fieldset>
   <br>
   SearchKe:<input type=text name="key" value="Bus" />
    Field:<input type=text name="field" value="" />
   <input type=submit onclick="search()" value="Search">
   </form>
   <script>
       document.write("<table border=1><tr><th>no.</th>");
    for(k in cultrans.DATA[0]) document.write("<th>"+k+"</th>");
    document.write("</tr></table><br>");
    function search() {
     var k=document.getElementsByName("key")[0].value;
     var key = new RegExp(k);
     var f=document.getElementsByName("field")[0].value;

  document.write("Data:<br><table border=1><tr><th>no.</th>");
  for(k in cultrans.DATA[0])
     document.write("<th>"+k+"</th>");
  document.write("</tr>");
  var cnt=0;
  for(i in cultrans.DATA) {
     if(key.test(cultrans.DATA[i][f])) {
        cnt++;
        document.write("<tr><td>"+i+"</td>");
        for(k in cultrans.DATA[i]) document.write("<td>"+cultrans.DATA[i][k]+"</td>");
        document.write("</tr>");
     }
  }
  document.write("<tr><th>Found</th><th>"+cnt+"</th><td colspan=4>End of Search</td></tr>");
  document.write("</table>");
}
</script>
   </body>

Q: I want to apply the checked checkbox information to the search() function.

Thank you so much and have a good day <:

ddddddddddddddddddddddddddddddddddddddddddddddddddddddddafsfsafsaffasssssfsafsafsaf safgg dg dg dg sdg sdg sdg dsg dsqwefgrehafx




Aucun commentaire:

Enregistrer un commentaire