Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Re: R: RE: Filling a combo box


Message #1 by "Michael W Pickens" <HO0MWP@F...> on Mon, 4 Mar 2002 12:41:07 -0500

Giovanni:



Actually that was very helpful.  Thank you so much.



I hope you don't mind but I have one more question for you. When the user

selects a pdf how can I open up the page for them?  So if the select

hello.pdf in the combo box how can I open the hello.pdf for them.  I know

that I can use the request.form("cboStores") to get the value from the

combo box.  I just don't know how to automatically have the page appear

after the click.  I am guessing that I could write something with VBScript

using the onkeypress or just add a submit button which is what I have done.

How do I get it to automatically go to the page I want though.



Again thank-you so much for all of your help so far.



M!

















"Giovanni Salucci" <g.salucci@n...> on 03/04/2002 10:11:43 AM



Please respond to "ASP Databases" <asp_databases@p...>



To:   "ASP Databases" <asp_databases@p...>

cc:



Subject:  [asp_databases] R: RE: Filling a combo box







can use FileSystemObject and Server.MapPath

if all your pdf files are in a directory named PDF









     ' File System Object

     Dim fso

          Set fso = Server.CreateObject("Scripting.FileSystemObject")



     ' "PDF" Folder

     Dim folder

          Set folder = fso.GetFolder(Server.MapPath("\PDF"))

          ' or the physical path

          'Set folder = fso.GetFolder("C:\Inetpub\wwwroot\PDF")



     If folder.Size > 0 Then %>



          <select NAME="pdf_name" SIZE="1">

          <option VALUE="0">Choose a File</option>



          <% For Each file In folder.Files %>





               <option VALUE="<%=file.Name%>"><% Response.write file.Name &

"  (" &

file.Size & ")"%></option>





          <%Next

     Else

          Response.Write "No pdf available"

     End If



Set folder = Nothing

Set fso = nothing



     %>



     </select>







HTH

Giovanni





-----Messaggio originale-----

Da: Michael W Pickens [mailto:HO0MWP@F...]

Inviato: lunedi 4 marzo 2002 15.59

A: ASP Databases

Oggetto: [asp_databases] RE: Filling a combo box









Colin thanks for replying to my post.  I appreciate you taking time out of

your busy schedule to tring and help.  If anyone who is reading these knows

how to fill a combo box using the file names of pdfs on the directory of

the server I would much appreciate knowing the answer.





Colin, I have filled a combo box before using a recordset from a database.

So I am a little familiar with that.  However, I have no idea on how to

find the names of the files on the web directory or on the C drive to

populate this combo box.  I have never done this before and the books just

cover filling in a combo box using a recordset.



I am using PWS as this is just an intranet site.  However, using the <A

ref> and the putting the files in the web directory it does not look like

it is giving the user the address of where the file is stored so I think it

is relatively safe right?  Am I missing something here?  I don't want the

users to have complete access to these files but to be able to view them.



M!









Colin.Montgomery@C... on 03/04/2002 09:34:25 AM



Please respond to "ASP Databases" <asp_databases@p...>



To:   "ASP Databases" <asp_databases@p...>

cc:



Subject:  [asp_databases] RE: Filling a combo box





i'm not sure about how to return an array/recordset of all the files in a

particular directory on the server - hopefully someone else can help u out

with that - but I have a couple of pointers 4 u:



Consider storing your PDFs in a non-published directory.  Then create a

virtual directory using IIS to point to this folder.  This just allows you

more freedom to move the documents onto a storage server.  This would have

the knockon effect that staff who upload the PDF files can map a drive on

their local machine and simply drag the files there - no need to have

access

to the Web server.



Also, you can't think of a combo box as being an object in ASP.  What you

do

is use your ASP code to write out the necessary HTML for a combo box, using

your loop to add the necessary number of <OPTION VALUE tags (1 for each PDF

that is).  E.g.

<OPTION VALUE="<%=rs(FileName)%>">



HTH,

Col



-----Original Message-----

From: Michael [mailto:michael.pickens@f...]

Sent: 04 March 2002 13:50

To: ASP Databases

Subject: [asp_databases] Filling a combo box





I have a combo box that I want to fill up with the name of pdf files that

will be stored in the "inetpub/wwwroot" folder.  This way the user can

choose which file they want to see and then I can use the <a href> to

bring up the file for them.  I have done this before in VB but never in

ASP.  Below is what I tried but as you can guess it didn't work.  The name

of my combo box is cboStores.  Below is the code I tried which is what I

use in VB.  Any suggestions would be greatly appreciated.







<SCRIPT Language = VBScript>

Const Folder1 = "C:\Stores"

Const ExtSpec1 = "*.pdf"



strFileName1 = Dir(Folder1 & ExtSpec1)

Do While Len(strFileName1)

    strLength = Len(strFileName1) ' Get report name length

    strDeleteRPT = strLength - 4

  cboStores.AddItem Left(strFileName1, strDeleteRPT)

  strFileName1 = Dir

Loop



</SCRIPT>




$subst('Email.Unsub').





*******



This message and any attachment are confidential and may be privileged or

otherwise protected from disclosure.  If you are not the intended

recipient, please telephone or email the sender and delete this message and

any attachment from your system.  If you are not the intended recipient you

must not copy this message or attachment or disclose the contents to any

other person.



For further information about Clifford Chance please see our website at

http://www.cliffordchance.com or refer to any Clifford Chance office.






$subst('Email.Unsub').


















$subst('Email.Unsub').








$subst('Email.Unsub').













Message #2 by "Giovanni Salucci" <g.salucci@n...> on Mon, 4 Mar 2002 16:11:43 +0100

can use FileSystemObject and Server.MapPath

if all your pdf files are in a directory named PDF









	' File System Object

	Dim fso

		Set fso = Server.CreateObject("Scripting.FileSystemObject")



	' "PDF" Folder

	Dim folder

		Set folder = fso.GetFolder(Server.MapPath("\PDF"))

		' or the physical path

		'Set folder = fso.GetFolder("C:\Inetpub\wwwroot\PDF")



	If folder.Size > 0 Then %>



		<select NAME="pdf_name" SIZE="1">

		<option VALUE="0">Choose a File</option>



		<% For Each file In folder.Files %>





			<option VALUE="<%=file.Name%>"><% Response.write file.Name & "  (" &

file.Size & ")"%></option>





		<%Next

	Else

		Response.Write "No pdf available"

	End If



Set folder = Nothing

Set fso = nothing



	%>



	</select>







HTH

Giovanni





-----Messaggio originale-----

Da: Michael W Pickens [mailto:HO0MWP@F...]

Inviato: lunedi 4 marzo 2002 15.59

A: ASP Databases

Oggetto: [asp_databases] RE: Filling a combo box









Colin thanks for replying to my post.  I appreciate you taking time out of

your busy schedule to tring and help.  If anyone who is reading these knows

how to fill a combo box using the file names of pdfs on the directory of

the server I would much appreciate knowing the answer.





Colin, I have filled a combo box before using a recordset from a database.

So I am a little familiar with that.  However, I have no idea on how to

find the names of the files on the web directory or on the C drive to

populate this combo box.  I have never done this before and the books just

cover filling in a combo box using a recordset.



I am using PWS as this is just an intranet site.  However, using the <A

ref> and the putting the files in the web directory it does not look like

it is giving the user the address of where the file is stored so I think it

is relatively safe right?  Am I missing something here?  I don't want the

users to have complete access to these files but to be able to view them.



M!









Colin.Montgomery@C... on 03/04/2002 09:34:25 AM



Please respond to "ASP Databases" <asp_databases@p...>



To:   "ASP Databases" <asp_databases@p...>

cc:



Subject:  [asp_databases] RE: Filling a combo box





i'm not sure about how to return an array/recordset of all the files in a

particular directory on the server - hopefully someone else can help u out

with that - but I have a couple of pointers 4 u:



Consider storing your PDFs in a non-published directory.  Then create a

virtual directory using IIS to point to this folder.  This just allows you

more freedom to move the documents onto a storage server.  This would have

the knockon effect that staff who upload the PDF files can map a drive on

their local machine and simply drag the files there - no need to have

access

to the Web server.



Also, you can't think of a combo box as being an object in ASP.  What you

do

is use your ASP code to write out the necessary HTML for a combo box, using

your loop to add the necessary number of <OPTION VALUE tags (1 for each PDF

that is).  E.g.

<OPTION VALUE="<%=rs(FileName)%>">



HTH,

Col



-----Original Message-----

From: Michael [mailto:michael.pickens@f...]

Sent: 04 March 2002 13:50

To: ASP Databases

Subject: [asp_databases] Filling a combo box





I have a combo box that I want to fill up with the name of pdf files that

will be stored in the "inetpub/wwwroot" folder.  This way the user can

choose which file they want to see and then I can use the <a href> to

bring up the file for them.  I have done this before in VB but never in

ASP.  Below is what I tried but as you can guess it didn't work.  The name

of my combo box is cboStores.  Below is the code I tried which is what I

use in VB.  Any suggestions would be greatly appreciated.







<SCRIPT Language = VBScript>

Const Folder1 = "C:\Stores"

Const ExtSpec1 = "*.pdf"



strFileName1 = Dir(Folder1 & ExtSpec1)

Do While Len(strFileName1)

    strLength = Len(strFileName1) ' Get report name length

    strDeleteRPT = strLength - 4

  cboStores.AddItem Left(strFileName1, strDeleteRPT)

  strFileName1 = Dir

Loop



</SCRIPT>




$subst('Email.Unsub').





*******



This message and any attachment are confidential and may be privileged or

otherwise protected from disclosure.  If you are not the intended

recipient, please telephone or email the sender and delete this message and

any attachment from your system.  If you are not the intended recipient you

must not copy this message or attachment or disclose the contents to any

other person.



For further information about Clifford Chance please see our website at

http://www.cliffordchance.com or refer to any Clifford Chance office.






$subst('Email.Unsub').


















$subst('Email.Unsub').




  Return to Index