0

can anybody tell me what is wrong with my code. I am tring to create a table filter, this is my javascript code:

 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";
  }
}
}
} 

this is my 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(); ?>
1
  • Update your question to include what you're trying to accomplish and what the error is. Commented May 10, 2012 at 11:00

1 Answer 1

2

In first line you have written

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

The whole means

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

Which is wrong

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I am new to javascript, so forgive me, on track with my function now thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.