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.
<%@ 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.