« Previous Next »

Thread: How to create a search field for an ASP script that lists the contents of a directory ?

Last post 04-25-2006 8:33 AM by jeff@zina.com. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 04-23-2006, 6:32 PM

    • admicom
    • Not Ranked
    • Joined on 04-23-2006, 10:22 PM
    • Posts 0

    How to create a search field for an ASP script that lists the contents of a directory ?

    Hi,

    I'd like to know how to create a search field for an ASP script that lists the contents of a directory. In fact, I have created a web site that my customers can access. They have a login and a password. Depending of their login, they can access a private page. This private page lists the contents of their 3 directories (invoices, reports and estimates). So, I juste have to save my PDF docs into these directories and my customers can view these documents from their private web access. When there are a lot of documents listed, it is difficult for them to find the apropriate document. So, I'd like to create a search field to help them to find the right document. They enter a piece of text and the system finds the documents in the directory that match to the search.

    Please help me !!!!

    Here is my code without the search field :

    <% Set FSO = _
       Server.CreateObject("Scripting.FileSystemObject")
    dir = Server.MapPath("docs/rapports/")
    set fc=FSO.getFolder(dir).files

    dim toplk(5,2) : maxtop = 5

    for each f in fc ' lecture et tri par date de création
       for k = 1 to maxtop
          if f.datecreated > toplk(k,1) then
             s0 = f.datecreated : u0 = f.name
             for kk = k to maxtop
                s = toplk(kk,1) : u = toplk(kk,2)
                toplk(kk,1) = s0 : toplk(kk,2) = u0
                s0 = s : u0 = u
             next
             exit for
          end if
       next
    next
    %>
    </font>
    <p><u><b><font face="Verdana">Rapports d'intervention</font></b></u></p>
      <font face="Verdana" size="2">
    <%
    for p = 1 to maxtop ' affichage
    %></font><A target="_blank" href="docs/rapports/<%=toplk(p,2)%>"><font face="Verdana" size="2" color="#000080">
          <%=replace(toplk(p,2),".asp","")%>
          <p></p>
    </font>
       </A>
    </font>
      <font face="Verdana" size="2">
    <%next %></font></td>
      <td align="center" width="33%" height="1028" valign="top"><% Set FST = _
       Server.CreateObject("Scripting.FileSystemObject")
    dir = Server.MapPath("docs/devis/")
    set fd=FST.getFolder(dir).files

    dim toplt(5,2) : maxtop = 5

    for each f in fd ' lecture et tri par date de création
       for t = 1 to maxtop
          if f.datecreated > toplt(t,1) then
             s0 = f.datecreated : u0 = f.name
             for tt = t to maxtop
                s = toplt(tt,1) : u = toplt(tt,2)
                toplt(tt,1) = s0 : toplt(tt,2) = u0
                s0 = s : u0 = u
             next
             exit for
          end if
       next
    next
    %>

    Thanks

    Nicolas (Lyon in FRANCE)

  • 04-25-2006, 8:33 AM In reply to

    Re: How to create a search field for an ASP script that lists the contents of a directory ?

    Why not go further and use Indexing Services?  Take a look at SimonGibson.com for some good help and an inexpensive pre-done search script.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
Page 1 of 1 (2 items)
Microsoft Communities