|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
||||
|
||||
|
Direcotry listing in combo box
Ok, first off, I know absolutly nothing about ASP (though I plan to learn at some point). I just need a script so I can get a project I'm working on done. That being said, I need to take the listing of a directoy on the web site (a folder called drawing in the web pages directory) and dump it into a combo box for the user to select from. When the user selects an item, it need to set a session variable that contains the filename so i can access it later on in a javascript. I think that its pretty simple, but as I said, I'm clueless about it. Thanks.
__________________
Every morning, I get up and look through the Forbes list of the richest people in America. If I'm not there, I go to work. May your Tongue stick to the Roof of your Mouth with the Force of a Thousand Caramels. To the systems programmer, users and applications serve only to provide a test load. |
|
#2
|
|||
|
|||
|
How the hell are you able to say this if you know nothing about asp?
I assume you know some form of PHP or Perl..... but if this the case just use vbscript and the FSO object to open up the directory, dump it in a loop. Check out sloppycode.net who have FSO well documented with all it's methods. The session creation should come easy to you i would think if you've done programming before... it's all well documented, learn to use google first If you're having problems with this post the errors... |
|
#3
|
||||
|
||||
|
Thanks for the link. I have done some pprogramming before so it shouldnt be too hard, I was just looking for some pointers (which I got
). Never done anything with vbscript, but I do have a book on it laying around.... Anyways, thanks for the reply! |
|
#4
|
||||
|
||||
|
Ok, I got a problem (figures...). I've been messing around with it, and when I try to do this
Code:
...
<%
set fso = server.createobject("Scripting.FileSystemObject")
drawingspath = Server.MapPath(".\") & "\drawings"
Response.Write drawingspath
form1.textfoo.Value = "foobar!"
%>
...
<form name="form1">
<select name="thingy"> </select>
<input type="button" name="Show" value="Show">
<input type="text" name="textfoo" size=10>
</form>
it craps out on me when I try to view the page and says Code:
Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: '' /cad-view/cadview.asp, line 12 Whats causing this? Line 12 is the line that begins with form1. |
|
#5
|
|||
|
|||
|
ooh cool, a unix guy
ok, step on of asp, is root is just \, no .\ step 2, is FSO, i think you're trying to display the names of all the folders right? Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(Server.Mappath("\"))
Set subFolders = folder.SubFolders
For Each folderObject in SubFolders
Response.Write folderObject.Name & "<BR>"
Next
just add the folder you want to start on at the end of the getfolder line, so & "\drawings.asp" assuming that's a folder in root.... if this asp page IS drawings, it'd be wise just to mappath to "drawings.asp", then you don't even have to know the absolute path/virtual. ahh, the joys of the mappath method. secondly, you need to now put this in the drop down... make your code this.. Code:
<form name="form1">
<select name="thingy">
<%
<form name="form1">
<select name="thingy">
<%
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(Server.Mappath("\"))
Set subFolders = folder.SubFolders
For Each folderObject in SubFolders
Response.Write "<option>" & folderObject.Name & "</option>"
Next
%>
</select>
<input type="button" name="Show" value="Show">
<input type="text" name="textfoo" size=10 value="
<%=fso.GetFolder(Server.Mappath("\"))%>">
</form>
vbscript doesn't work like javascript, since the object doesn't exist when you get to the assign code, well it won't work and the assign is wrong. You have to give the text box the value as the browser is painting it like that last line, hope this helps. this displays all the folder names in root and lets you select them... it's up to you as to what you want to do with it now, let me know if you need some more help... pointers: change your button to a submit, and change the mappath root to mappath(request.form("textfoo")) to view whatever the user selects for a field, you might want to add some browse features so they don't have to know the absolute path.............. not to mention security issues.... Last edited by unatratnag : August 16th, 2003 at 08:34 AM. |
|
#6
|
||||
|
||||
|
Yeh, linux/unix is pretty cool. I dont use it too much though cause I cant run most of my apps on it, and I love not having to do much screwing around to get things to work right in Windows. But thats just me.
![]() Heres what I'm trying to do with this page. In the directory where this page will reside, I have another directory call 'drawings'. What I'm trying to do (and have accomplished) is to list all the files in this directory that have a '.dwf' extension. The submit button will eventually refresh a seperate frame that will make use of whatever is selected in the combo box. Here's what I've done: Code:
<form name="form1">
<select name="menu">
<%
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(Server.Mappath("drawings"))
Set files = folder.Files
For Each file in SubFolders
If Right(file, 4) = ".dwf" Then
Response.Write "<option value=" & file.Name & ">" & Replace(file.Name, ".dwf", "") & "</option>"
End If
Next
%>
</select>
<input type="button" name="Submit" value="Submit">
<input type="text" name="textfoo" size=10>
</form>
It works perfectly (at least as far as I can tell). Now I just need a way to check whats selected in the combo box from another frame. Any pointers on that? I'm probably trying to learn too fast... Many, many thanks for all the help you've given me! ![]() |
|
#7
|
|||
|
|||
|
when you submit to the other page, it will be in the value request.form("menu")
make sure you tell you <form> tag its action is post and where (what page) the form will post too. something like this Code:
<form name="frmForm" action="YourScript.asp" method="post"> then on YourScript.asp, first line <%=request.form("Menu")%> and that will print out which file you selected. |
|
#8
|
|||
|
|||
|
my question is what the hell is the input box for then?
|
|
#9
|
||||
|
||||
|
Heh, I was just messing around with vbscript really, figuring out how to do stuff, etc. There was an example in my book that used a text box and showed how to set its value. So its pretty useless.
![]() |
|
#10
|
||||
|
||||
|
Alrighty, I got the sumbit to work, sorta. There are two main problems with it. First, it displays the frame separetly instead of just updating that frame. Second, it only writes out up to the first space. How do I fix this?
|
|
#11
|
|||
|
|||
|
not sure, i'm a youngin and the new hotttness is using tables instead of frames. I'd recommend actually doing it this way due to easyness. In the future try just having a table 4 sections
<table> <tr><td> header </td></tr> <tr><td>links </td> <td> body</td> </tr> <tr><td>footer </td></tr> then just do includes on the body/footer/header etc... frames are really not for bigginers. What I know, is there are commands where you tell what frame to load what, you need to get the body frame that you're using to load the page your submitting to. I'm not sure i understand what you mean by it's only writing up to the first space, the request.form should grab the whole string selected if you set up the value correct. Look at the HTML, does it say value=some sentence. If so, you need to change it to value="some sentence" do this by "<option value=""" & file.Name & """>" scrarry huh? "" prints out a " to the screen, don't ask me why, it's lame, but that's how you do it. the third " just closes the string in case you're confused, that should solve the only grabbing first letter. |
|
#12
|
||||
|
||||
|
The quote thing worked just fine, though it does seem sorta wierd. Anyways, I didnt know that you could update the contents of a table. How do you do it?
|
|
#13
|
||||
|
||||
|
Ok, except for a few little things, its pretty much done. Here it is:
Code:
<% @language="vbScript" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#99CCCC">
<div align="right">
<form name="form1" action="cadview.asp" method="post">
<select name="menu">
<%
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(Server.Mappath("drawings"))
Set subFolders = folder.Files
For Each file in SubFolders
If Right(file, 4) = ".dwf" Then
Response.Write "<option value=""" & "drawings/" & file.Name & """>" & Replace(file.Name, ".dwf", "") & "</option>"
End If
Next
%>
</select>
<input type="submit" name="Submit" value="submit">
</form>
</div>
<% Response.Write request.form("menu") %>
<center>
<object id='FNDWF82'
classid='clsid:B2BE75F3-9197-11CF-ABF4-08000996E931'
width=100%
height=100%
align=Left>
<param name='Filename' value='drawings/8th floor.dwf'>
<param name='UserInterface' value='on'>
<param name='BackColor' value='#000000'>
<embed
width=100%
height=89%
filename='<% Response.Write request.form("menu") %>'
userinterface='on'
backcolor='#000000'
align='Center'
name='FNDWF'
pluginspage='http://www.autodesk.com/prods/whip'
src='<% Response.Write request.form("menu") %>'></embed> </object>
</center>
</body>
</html>
|
|
#14
|
|||
|
|||
|
the tables aren't 'updated'
you submit to a new page where the require is diffent. But the template is set so all you do is create the body and the header and links all stay the same, you just change the body. That's generally the way things are done these days. That and including css and templates but that's later for you =) frames tend to be bitchy and so that's the bad cousin that I don't like to talk about. |
|
#15
|
||||
|
||||
|
Ok, that makes sense. Thanks. And I agree that frames do seem to be somewhat troublesome
![]() |