Solved

Web design Help Search Bar and Directory Listing

Posted on 2013-12-03
21
595 Views
Last Modified: 2013-12-05
Designing a website for accessing my mp3 files.

I would like to have a search bar be able to search for music by Album Name, Artist Name and Song Name.

Also I would like to List the contents of the music folder as a display and they define a button so that you can play that mp3 song.

I have been working on this for the past few days and a bit stumped.

I attached my page see below

I am new to web design

Any help would be great

Code Snippet Added:
<html>
 <body bgcolor="yellow">
 <center>
<h2> Welcome to Tom's MP3 Music Site!</h2>
 </center>
 
<table width="150" border="0" cellspacing="0" cellpading="5">
<tr>
  <td colspan="2">Search</td>
</tr>
<tr>
  <td>
	<input type="text" name="Query" size="15" />
  </td>
  <td>
	<input type="button" name="Search" value="GO!!" onclick="doSearch(this.form.Query);"/>
   </td>
  </tr>
</table>

<head>
<script>var isDocBeingEdited = " + @If(@IsDocBeingEdited; "true"; "false") + ";</script>

<script>

function doSearch ( s ) {
 var regExp1 = /\bfield\b/;
 var regExp2 = /[(,),<,>,\[,\]]/;
 var str = s.value; if ( str == "" ){ 
 alert("Please be sure to enter something to search for.");
 s.focus();
 } else { 
 if ( typeof regExp1.source != 'undefined' ) //supports regular expression testing 
 if ( regExp1.test( str ) || regExp2.test( str ) ){
 var alrt = "Please note that you can not include:"; 
 alrt += "\n\nThe reserved word 'field'\nthe characters [, ], (, ), < or >";
 alrt += "\n\nin your search query!\n\nIf you are confident that you know";
 alrt += "\nwhat you are doing, then you can\nmanually produce the URL required."
 s.focus();
 return alert( alrt );
 }
 openDbRelativeURL("All?SearchView&Query=" + escape( str ) + "&start=1&count=10");
 }
 }
</script>
<script for=window event="onload()">
 document.forms[0].onsubmit = returnFalse;
 </script>


</head>
</body>
</html> 
<script>
<%@ page import="java.io.File" %>
<%
  String selectedFile = request.getParameter("selectedFile");
  if(selectedFile == null || "Please make a selection".equals(selectedFile))selectedFile = "not selected";
%>
</script>
<html>
<body>
<form>
<select name="selectedFile" >
<option value="Please make a selection" >Please make a selection</option>
<%
   File folder = new File(application.getRealPath("/test"));
   String[] fileList = folder.list();
   //for(int x = 0 ; x < fileList.length ; x++){
   for(String fileName : fileList){
           out.print("<option value=\"" + fileName + "\">" + fileName + "</option>");
   }
%>
</select>
<input type="submit" />
</form>
Selected file is <%=selectedFile%>

</body>
</html>

Open in new window

music.htm
0
Comment
Question by:Thomas Grassi
21 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
I see you are new to PHP.  If you want to learn to create web pages using PHP, this article will help you get started.  I do not see any PHP in the code you posted, but you might enjoy learning the language.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Thanks for responding.

Good reading.

Did you see any code issues with my example?

Can t seem to get it to work
0
 
LVL 42

Expert Comment

by:Chris Stanyon
Comment Utility
Your code isn't PHP - it's ASP!!
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Thanks Ray was not sure which groups to add to.
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
Comment Utility
here is some code that'll write out to the screen all files in a particular folder. You can tweak it so that instead of writing out the files, you can loop through them and check for the criteria you want:

<% ListFolderContents(Server.MapPath("/path/to/main/folder")) %>
<% sub ListFolderContents(path)

     dim fs, folder, file, item, url

     set fs = CreateObject("Scripting.FileSystemObject")
     set folder = fs.GetFolder(path)

    'Display the target folder and info.

     Response.Write("<h2>"& folder.Name &"</h2>")

     'Display a list of sub folders.

     for each item in folder.SubFolders
                ListFolderContents(item.Path)
     next

     'Display a list of files.
Response.Write("<ul>")
    for each item in folder.Files
       url = MapURL(item.path)
        Response.Write("<li><a href=""" & url & """>" & item.Name & "</a></li>")
    next
        Response.Write("</ul>")
   end sub


   function MapURL(path)

     dim rootPath, url

     'Convert a physical file path to a URL for hypertext links.

     rootPath = Server.MapPath("/")
     url = Right(path, Len(path) - Len(rootPath))
     MapURL = Replace(url, "\", "/")

end function %>

Open in new window


source

and to search the metadata for a MP3, you can check out this tutorial from 4GuysFromRolla

http://www.4guysfromrolla.com/webtech/tips/t041701-1.shtml
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Thanks

Question about this line of your code

<% ListFolderContents(Server.MapPath("/path/to/main/folder")) %>

This is on a Windows 2003 Server IIS 6 server
Has a share to a NAS drive mapped as M drive  folder is Music
M:\music\mp3 music albums

How would I access this using this code?
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
try creating a virtual folder in your site (through IIS) that maps to the M:| drive
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Thanks created a virtual directory and the alias is named MP3

so would this be correct?

<% ListFolderContents(Server.MapPath("/mp3/mp3 music albums")) %>
<% sub ListFolderContents(path)
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
that looks correct, yes
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Great will test tonight
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
The Big Daddy

tested but it failed see below

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed.

Source Error:

 

Line 8:  
Line 9:  <% ListFolderContents(Server.MapPath("/mp3/mp3 music albums")) %>
Line 10: <% sub ListFolderContents(path)
Line 11:
Line 12:      dim fs, folder, file, item, url
 

Source File: c:\inetpub\wwwroot\music_9.aspx    Line: 10



Show Detailed Compiler Output:


c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_eo33w16-.dll" /debug- /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls  "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_eo33w16-.0.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_eo33w16-.1.vb"


Microsoft (R) Visual Basic Compiler version 8.0.50727.3053
for Microsoft (R) .NET Framework version 2.0.50727.3649
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_eo33w16-.0.vb(132) : error BC30188: Declaration expected.

            __w.Write(" "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</body>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"</html>")
            ~~~                                                                                                                                                                                                                                                                                                                                              
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_eo33w16-.0.vb(133) : error BC30429: 'End Sub' must be preceded by a matching 'Sub'.

        End Sub
        ~~~~~~~
c:\inetpub\wwwroot\music_9.aspx(10) : error BC30289: Statement cannot appear within a method body. End of method assumed.

   sub ListFolderContents(path)
   ~~~                        
c:\inetpub\wwwroot\music_9.aspx(10) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

   sub ListFolderContents(path)
                          ~~~~
c:\inetpub\wwwroot\music_9.aspx(12) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

     dim fs, folder, file, item, url
         ~~                        
c:\inetpub\wwwroot\music_9.aspx(12) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

     dim fs, folder, file, item, url
             ~~~~~~                
c:\inetpub\wwwroot\music_9.aspx(12) : warning BC42024: Unused local variable: 'file'.

     dim fs, folder, file, item, url
                     ~~~~          
c:\inetpub\wwwroot\music_9.aspx(12) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

     dim fs, folder, file, item, url
                     ~~~~          
c:\inetpub\wwwroot\music_9.aspx(12) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

     dim fs, folder, file, item, url
                           ~~~~    
c:\inetpub\wwwroot\music_9.aspx(12) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

     dim fs, folder, file, item, url
                                 ~~~
c:\inetpub\wwwroot\music_9.aspx(14) : error BC30807: 'Let' and 'Set' assignment statements are no longer supported.

     set fs = CreateObject("Scripting.FileSystemObject")
     ~~~                                                
c:\inetpub\wwwroot\music_9.aspx(15) : error BC30807: 'Let' and 'Set' assignment statements are no longer supported.

     set folder = fs.GetFolder(path)
     ~~~                            
c:\inetpub\wwwroot\music_9.aspx(37) : warning BC42021: Function without an 'As' clause; return type of Object assumed.

   function MapURL(path)
            ~~~~~~      
c:\inetpub\wwwroot\music_9.aspx(37) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

   function MapURL(path)
                   ~~~~
c:\inetpub\wwwroot\music_9.aspx(39) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

     dim rootPath, url
         ~~~~~~~~    
c:\inetpub\wwwroot\music_9.aspx(39) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed.

     dim rootPath, url
                   ~~~

 




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3649; ASP.NET Version:2.0.50727.3653


now this is an aspx file I only have asp files that I use this is the first aspx file I am trying.

Can it be something in IIS I am missing?

IIS 6 on Windows 2003 Server
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
you originally posted classic asp code, so i gave a classic asp example. you'll have to convert it to .NET if you want to use aspx pages
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
Ooops my fault here

I have another music_7.aspx that works on my site So it is not aspx it is something in the code.

The error is on line 10 any ideas?

you can do this http://www.tgcsnet.com/music_9.aspx

http://www.tgcsnet.com/music_7.aspx  works but that is a sample I was testing.
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
the example i gave is strictly classic asp, which is a totally different language from asp .net. I don't know .net enough to convert it over, so you can either use classic asp or wait until an expert comes along that can give a .net answer (you may want to ask a new question for that)
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
not sure what you mean by classic asp

I have the file named music_9.aspx should I rename it to music_9.asp?
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
classic asp is an event driven language that came out before .NET. It's very similar to PHP, just with different syntax.

ASP.NET is an object oriented language. You cannot mix the 2. You also have to make sure you have your web server configured to run classic asp (newer versions of IIS have it turned off by default.

i think the first step you need to do is decide what platform works best and is most comfortable for you.
0
 
LVL 23

Author Comment

by:Thomas Grassi
Comment Utility
I just checked my IIS 6 I have ASP.NET version 2.0.50727 installed

So it looks like I need to convert your code to asp.net.
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
yes, if the rest of your app is written in .NET and that's the language you want to program in
0
 
LVL 23

Author Closing Comment

by:Thomas Grassi
Comment Utility
Working on code now
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now