Javascript未捕获的TypeError:value.toUpperCase不是函数

新事物

我正在尝试使用以下脚本让用户根据它们键入的值来过滤表中的行。他们可以更新该行,在发生更新事件后,页面将刷新/重新显示,并且页面将再次显示所有行。我试图找到一种方法来保持刷新/重新加载发生后它们被过滤的行。换句话说,好像刷新从未发生过。

I get the following error: Uncaught TypeError: value.toUpperCase is not a function
    at filterTable (accounts.php:1270)
    at HTMLInputElement.<anonymous> (accounts.php:1291)
    at HTMLInputElement.<anonymous>

这是代码;

  <table class="userprof" align='left'>
    <tr>
      <td class="footer">Filter:
        <input type="text" id="myInput" name="filter" style="color:black !important;" placeholder="Filter table" />
      </td>
    </tr>
  </table>
</p><br /><br /><br />
    

    
</head>


    <table width="99%" id="myTable" class="sortable" >
    <tr>
 
    <td class="header" style="padding: 1px;">Name</td>
    <td class="header">Email</td></tr>
 
 
<?  //Selecteer accounts.
  

  $stmt = $mysqli->prepare("SELECT * FROM account WHERE purpose= ?");
  $stmt->bind_param("s", $status);
  $stmt->execute();
  $result = $stmt->get_result(); 
}
 while ($row = $result->fetch_assoc()) { 

  
    <td style="color:<?= htmlspecialchars($cat_color) ?> ", class="footer"><?= htmlspecialchars($row['name']) ?></td>
    

    <td style="color:<?= htmlspecialchars($cat_color) ?> ", class="footer"><?= htmlspecialchars($row['email']) ?></td>
  
    
    <td class="footer" width="1px"><input type="button" value="Edit" id="<?php echo htmlspecialchars($row['id']); ?>" onClick="this.style.color='gold';"
    class="submit edit_data" /></td>
  
   
    </form>
    </tr>
    
    
    <? } ?>
    </table><div id="bottom"></div>

    <script type="text/javascript">
// Store the input in a variable for reference.
var myInput = document.getElementById("myInput");
var savedValue = getSavedValue("myInput");

// Immediately filter the table and set the input value.
filterTable(savedValue);
myInput.value = savedValue;

//Save the value function - save it to localStorage as (ID, VALUE)
function saveValue(e) {
  var id = e.id; // get the sender's id to save it . 
  var val = e.value; // get the value. 
  localStorage.setItem(id, val); // Every time user writing something, the localStorage's value will override . 
}

//get the saved value function - return the value of "v" from localStorage. 
function getSavedValue(v) {
  if (!localStorage.getItem(v)) {
    return ""; // You can change this to your default value. 
  }
  return localStorage.getItem(v);
}

function filterTable(value) {
  console.log(value);
  var filter = value.toUpperCase();
  var rows = document.querySelector("#myTable tbody").rows;

  for (var i = 0; i < rows.length; i++) {
    var nameCol = rows[i].cells[1].textContent.toUpperCase();
    var rankCol = rows[i].cells[2].textContent.toUpperCase();
    var rankerCol = rows[i].cells[5].textContent.toUpperCase();
    var typeCol = rows[i].cells[6].textContent.toUpperCase();
    var emailCol = rows[i].cells[3].textContent.toUpperCase();
    if (nameCol.indexOf(filter) > -1 || rankCol.indexOf(filter) > -1 || rankerCol.indexOf(filter) > -1 || typeCol.indexOf(filter) > -1 || emailCol.indexOf(filter) > -1) {
      rows[i].style.display = "";
    } else {
      rows[i].style.display = "none";
    }
  }
}

myInput.addEventListener('keyup', function(event) {
  console.log(event); // Check if the event is fired.
  var value = event.target;
  saveValue(event);
  filterTable(value);
});

</script>
乔纳森·阿克维特·奥金
myInput.addEventListener('keyup', function(event) {
 console.log(event); // Check if the event is fired.
 var value = event.target.value;
 saveValue(event);
 filterTable(value);
});

它应该是event.target.value。您错过了价值属性

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Javascript中的“未捕获的TypeError:x.toUpperCase不是函数”

来自分类Dev

JavaScript关闭:未捕获的TypeError:counter.value不是函数

来自分类Dev

未捕获的TypeError:undefined不是函数-Javascript

来自分类Dev

Javascript“未捕获的TypeError:对象不是函数”

来自分类Dev

JavaScript OOP:未捕获的TypeError:不是函数

来自分类Dev

Javascript:未捕获的TypeError:不是函数

来自分类Dev

JavaScript WordPress未捕获的typeerror $不是函数

来自分类Dev

在Hello World应用程序上反应错误“未捕获的TypeError:type.toUpperCase不是函数”

来自分类Dev

未捕获的TypeError:$(…).on不是函数

来自分类Dev

获取错误未捕获的TypeError:value.replace不是函数

来自分类Dev

未捕获的TypeError:ctx.fillText不是函数(Javascript画布)

来自分类常见问题

未捕获的TypeError:Object.values不是JavaScript函数

来自分类Dev

Javascript。未捕获的TypeError:Hashids不是构造函数

来自分类Dev

Javascript-未捕获的TypeError:string不是函数

来自分类Dev

JavaScript错误:未捕获的TypeError:a [b]不是函数

来自分类Dev

未捕获的TypeError:$(...)。stellar不是函数

来自分类Dev

未捕获的TypeError:$ .cookie不是Dialog的函数

来自分类Dev

未捕获的TypeError:$ .ajax(...)。成功不是函数

来自分类Dev

未捕获的TypeError:#<Object>不是函数

来自分类Dev

未捕获的TypeError:$ .growl不是函数

来自分类Dev

未捕获的TypeError:Undefined不是函数

来自分类常见问题

未捕获的TypeError:$ .post不是函数

来自分类Dev

未捕获的TypeError:$(...)。tokenfield不是函数

来自分类Dev

未捕获的TypeError:this.transitionTo不是函数

来自分类Dev

未捕获的TypeError:undefined不是函数

来自分类Dev

未捕获的TypeError:number不是函数

来自分类Dev

获取“未捕获的TypeError:$(...)。timeago不是函数”

来自分类Dev

未捕获的TypeError:undefined不是jQuery的函数

来自分类Dev

未捕获的TypeError:undefined不是函数

Related 相关文章

  1. 1

    Javascript中的“未捕获的TypeError:x.toUpperCase不是函数”

  2. 2

    JavaScript关闭:未捕获的TypeError:counter.value不是函数

  3. 3

    未捕获的TypeError:undefined不是函数-Javascript

  4. 4

    Javascript“未捕获的TypeError:对象不是函数”

  5. 5

    JavaScript OOP:未捕获的TypeError:不是函数

  6. 6

    Javascript:未捕获的TypeError:不是函数

  7. 7

    JavaScript WordPress未捕获的typeerror $不是函数

  8. 8

    在Hello World应用程序上反应错误“未捕获的TypeError:type.toUpperCase不是函数”

  9. 9

    未捕获的TypeError:$(…).on不是函数

  10. 10

    获取错误未捕获的TypeError:value.replace不是函数

  11. 11

    未捕获的TypeError:ctx.fillText不是函数(Javascript画布)

  12. 12

    未捕获的TypeError:Object.values不是JavaScript函数

  13. 13

    Javascript。未捕获的TypeError:Hashids不是构造函数

  14. 14

    Javascript-未捕获的TypeError:string不是函数

  15. 15

    JavaScript错误:未捕获的TypeError:a [b]不是函数

  16. 16

    未捕获的TypeError:$(...)。stellar不是函数

  17. 17

    未捕获的TypeError:$ .cookie不是Dialog的函数

  18. 18

    未捕获的TypeError:$ .ajax(...)。成功不是函数

  19. 19

    未捕获的TypeError:#<Object>不是函数

  20. 20

    未捕获的TypeError:$ .growl不是函数

  21. 21

    未捕获的TypeError:Undefined不是函数

  22. 22

    未捕获的TypeError:$ .post不是函数

  23. 23

    未捕获的TypeError:$(...)。tokenfield不是函数

  24. 24

    未捕获的TypeError:this.transitionTo不是函数

  25. 25

    未捕获的TypeError:undefined不是函数

  26. 26

    未捕获的TypeError:number不是函数

  27. 27

    获取“未捕获的TypeError:$(...)。timeago不是函数”

  28. 28

    未捕获的TypeError:undefined不是jQuery的函数

  29. 29

    未捕获的TypeError:undefined不是函数

热门标签

归档