Web Analytics Made Easy -
StatCounter HELP with filtered table results - CodingForum

Announcement

Collapse
No announcement yet.

HELP with filtered table results

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HELP with filtered table results

    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 --

    [CODE]
    <script>
    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.rows[a].style.display="table-row";
    }
    }
    </script>

    <table id="states" border=1>
    <tr><td>State</td><td>Code</td></tr>
    <tr><td>ALABAMA</td><td>AL</td></tr>
    <tr><td>ALASKA</td><td>AK</td></tr>
    <tr><td>MAINE</td><td>ME</td></tr>
    <tr><td>MARSHALL ISLANDS</td><td>MH</td></tr>
    </table>

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

    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?

    Comment


    • #3
      filter results in gridview

      Refer to this sample:

      Code:
      <%@ page autoeventwireup="true" codefile="FilterWithDropDownList.aspx.cs"
              inherits="GridView_FilterWithDropDownList" language="C#" masterpagefile="~/MasterPages/Default.master"
              title="GridView: Filter With DropDownList" %>
      
      <asp:content id="Content1" runat="Server" contentplaceholderid="ContentPlaceHolder1">
              Select Category:
              <asp:dropdownlist id="ddlCategories" runat="server" appenddatabounditems="True" autopostback="True"
                      datasourceid="sdsCategories" datatextfield="CategoryName" datavaluefield="CategoryID">
                      <asp:listitem text="All Categories" value="-1">
                      </asp:listitem>
              </asp:dropdownlist>
              <asp:sqldatasource id="sdsCategories" runat="server" connectionstring="<%$ ConnectionStrings:NorthwindConnectionString %>"
                      selectcommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">
              </asp:sqldatasource>
              <asp:gridview id="gvProducts" runat="server" autogeneratecolumns="False" datakeynames="ProductID"
                      datasourceid="sdsProducts" style="margin-top: 12px;">
                      <columns>
                              <asp:boundfield datafield="ProductID" headertext="ProductID" insertvisible="False"
                                      readonly="True" sortexpression="ProductID" />
                              <asp:boundfield datafield="ProductName" headertext="ProductName" sortexpression="ProductName" />
                              <asp:boundfield datafield="CategoryName" headertext="CategoryName" sortexpression="CategoryName" />
                      </columns>
              </asp:gridview>
              <asp:sqldatasource id="sdsProducts" runat="server" connectionstring="<%$ ConnectionStrings:NorthwindConnectionString %>"
                      selectcommand="SELECT [ProductID], [ProductName], [CategoryName] FROM [Alphabetical list of products] WHERE ([CategoryID] = CASE WHEN @CategoryID = -1 THEN [CategoryID] ELSE @CategoryID END) ORDER BY [ProductName]">
                      <selectparameters>
                              <asp:controlparameter controlid="ddlCategories" name="CategoryID" propertyname="SelectedValue"
                                      type="Int32" />
                      </selectparameters>
              </asp:sqldatasource>
      </asp:content>
      Don't forget to mark solution providing post as "Answered".
      It helps others to find correct solutions!

      Comment


      • #4
        But gridview doesn't work in classic ASP, and he *DID* post in the classic ASP forum.

        He also seemed to be looking for a JavaScript solution, so he should have posted in the JavaScript forum.
        Be yourself. No one else is as qualified.

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎