Web Analytics Made Easy -
StatCounter Filter results in table HELP - CodingForum


No announcement yet.

Filter results in table HELP

  • Filter
  • Time
  • Show
Clear All
new posts

  • Filter results in table HELP

    OK I am wanting to build a table that I can enter data in to and have people sort by a drop down box like the 4th table down on this list -- http://www.javascriptkit.com/script/...lefilter.shtml

    But I have followed those instructions step by step and it never works. I was told to use .asp I have changed my page to a .asp and now have no clue where to go from here. In searching this site I have found this code --

    function Filter(table){
    var f=document.getElementById('f').value.toUpperCase();
    for (a=1; a<table.rows.length; a++)
    if (table.rows[a].cells[0].innerHTML.toUpperCase().indexOf(f)!=0)
    table.rows[a].style.display="none"; else

    <table id="states" border=1>
    <tr><td>MARSHALL ISLANDS</td><td>MH</td></tr>

    <input type="text" name="f" id="f">
    <input type="button" value="Filter" onclick="Filter(document.getElementById('states'));">

    But it gives me a filter that I have to type in. I am looking for drop downs that allow me to filter so say you select drop down for fields that contain "A" then another drop down for a field that contains "B" so the results show fields that contain "A" and "B"

    And PS I am semi new to the code world so please don't assume I know some stuff dumb it down a little HAHA

  • #2
    No one knows how to do this?


    • #3
      Ok I have figured out a drop down box with the bar's name in it but now I cant figure out how to make it edit my table so when I select the bars name it just displays that bars information? Any one have any ideas please??

      $connect = mysql_connect("hosted.domain.com", "username", "password") or
      die ("Hey loser, check your server connection.");
      // Write out our query to get the list of bar names from our DB.
      $query = "SELECT Bar FROM Test";
      // Execute it, or return the error message if there's a problem.
      $result = mysql_query($query) or die(mysql_error());
      $dropdown = "<select name='Bar'>";
      //fetch_assoc will get the rows from the $result and put them into an array
      // the while loop then loops through the array wrapping the html code around the results
      // thus generating the dropdown with a list of your bar names
      while($row = mysql_fetch_assoc($result)) {
      $dropdown .= "\r\n<option value='{$row['Bar']}'>{$row['Bar']}</option>";
      $dropdown .= "\r\n</select>";
      echo $dropdown;
      $query="select * from Test";
      $result = mysql_query("SELECT * FROM Test where City='Murfreesboro'");
      <table border=1 style="background-color:#F0F8FF;" >
      <caption><EM>Murfreesboro Bars</EM></caption>
      <th>Bar Name</th>
      echo "</td><td>";
      echo $row['Bar'];
      echo "</td><td>";
      echo $row['City'];
      echo "</td><td>";
      echo $row['Address'];
      echo "</td><td>";
      echo $row['Phone'];
      echo "</td></tr>";
      echo "</table>";