0

谁能告诉我我的代码有什么问题。我正在尝试创建一个表过滤器,这是我的 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>
"; 动态复选框表(); ?>
4

1 回答 1

2

在第一行你写了

var q = this.value
  var v = q.value.toLowerCase();

整体的意思

var v=this.value.value.toLowercase();

哪个是错的

于 2012-05-10T11:08:09.100 回答