Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable passing issue (browsing drives/files) 1

Status
Not open for further replies.

cruford

Programmer
Dec 6, 2002
138
US
I am creating a page that will allow users to upload a picture to the IIS Server. I found some code in javascript and it's almost working but I need some syntax help. I'm new to javascript and not sure how to reference elements on the forms and pass variables correctly. Here is my entire page so far:


<%@ language="VBSCRIPT" %>
<html>
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 3.1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>File Browser</title>
</head>
<body>
<SCRIPT language="JavaScript">
function resubmit(DrvLetter)
{
alert("about to refresh")
document.frmBrowse.action="Browser.asp?Drive=" & DrvLetter;
alert("about to submit")
document.frmBrowse.submit();
}
</SCRIPT>
<%
Dim fso, drives, isReady, rootFolder, subFolders, files
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set drives = fso.drives
Set rootFolder = fso.GetFolder(Server.MapPath("/images"))
Set subFolders = rootFolder.subFolders
Set files = rootFolder.files

'Function to enumerate type of drive
Function getDriveType (driveType)
Dim retVal
Select Case driveType
Case 0 retVal = "Unknown"
Case 1 retVal = "Removable"
Case 2 retVal = "Fixed"
Case 3 retVal = "Network"
Case 4 retVal = "CD ROM"
Case 5 retVal = "RAM Disk"
End Select
getDriveType = retVal
End Function
%>
<form name="frmBrowse" method="post" action="Browser.asp">
<table border="1">
<tr><td>Drives</td><td><select name="cboDrives" onChange="resubmit('document.frmBrowse.cboDrives.Value')">
<%
For Each drive In drives%>
<option value="<%=drive.driveletter%>"><%=drive.path & " " & getDriveType(drive.drivetype)%></option>
<%Next%>
</select></td></tr>
<tr><td>Directories</td><td><select name="cboDir">

</select</td></tr>
</table>
</form>
<%
Set files = Nothing
Set subFolders = Nothing
Set rootFolder = Nothing
Set fso = Nothing
Set drives = Nothing
Set fso = Nothing
%>

</body>
</html>


This gets me a page that displays my drives and I get both alert messages. However my variable I'm passing to resubmit() is coming back 0. This is the location I'm at after I select something from the dropdown list:


If I take off the "Drive=" concatenation it submits fine but then I don't get the drive letter they selected. Anyone have any ideas. Basically I want the user to select a drive and then update the next list box with folders in that drive and once again after they select a folder the final list box will be populated with files. Sorry for the long post, thanks for any help.
 
Change your ampersand to a plus sign:

document.frmBrowse.action="Browser.asp?Drive=" & DrvLetter;

...should be:

document.frmBrowse.action="Browser.asp?Drive=" + DrvLetter;

'hope that does it for you!

--Dave
 
That was it, can you tell I'm a VB man :). Here's a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top