任何人都可以告诉我我的代码有什么问题。我想创建一个表过滤器,这是我的javascript代码:
function searchRegExFieldKeyUp() {
var q = this.value
var v = q.value.toLowerCase();
var rows = document.getElementsByTagName("tr");
var on = 0;
for ( var i = 0; i < rows.length; i++ ) {
var fullname = rows[i].getElementsByTagName("td");
fullname = fullname[0].innerHTML.toLowerCase();
if ( fullname ) {
if ( v.length == 0 || (v.length < 3 && fullname.indexOf(v) == 0) || (v.length >= 3 && fullname.indexOf(v) > -1 ) ) {
rows[i].style.display = "";
on++;
} else {
rows[i].style.display = "none";
}
}
}
}
这是我的HTML:
function dynamic_checkbox_table(){
// connect to the database
$con = mysqli_connect(DB_HOST,DB_SELECT,DB_PASSWORDSELECT,DB_PHYSBINDER) or die ('DB-connection failed...');
// query the database
$sql = "SELECT * FROM Models";
$result = mysqli_query($con,$sql) or die(mysqli_error() . "<br/>$sql");
// run through the results from the database, generating the checkboxes
?>
<Table id="ModelFilter">
<?php
while ($row = mysqli_fetch_assoc($result)) {
?>
<tr><td><li> <?php echo $row['Model'];?>
<br><input id="<?php echo $row['ModelID'] ?>" name="<?php echo $row['Model']?>" type="checkbox" /></li></td></tr></br>
“;
dynamic_checkbox_table();
?&GT;
答案 0 :(得分:2)
在第一行你写了
var q = this.value
var v = q.value.toLowerCase();
整体意味着
var v=this.value.value.toLowercase();
哪个错了