|
-
Dec 3rd, 2000, 03:51 PM
#1
Okay, so I have this site where it displays the working directories files with a checkbox for each file. If you check the box and hit "delete" it deletes the file from the server (kinda like geocities file manager). Does anyone know how refferr to each of the CHECKED checkboxes and their names? Here's my code:
Music.asp
<%@ Language="VBScript" %>
<html>
<head>
<%
'Define the File System Object and set variables
'FSO = FileSystemObject
Dim FSO, Folder, FolderContents, FileItem
Set FSO = CreateObject("Scripting.FileSystemObject") 'Create FSO
Set Folder = FSO.GetFolder("C:\muzak\soul") 'Declare folder to have contents displayed
Set FolderContents = Folder.Files
%>
<title><%= Response.Write(Folder.Name) %></title>
<style type="text/css">
body, table {color:#000000; font-family:Verdana; font-size:11px}
</style>
</head>
<body background="/images/bground.gif" bgcolor="#ffffff" text="#000000" marginheight="0" topmargin="0">
<form action="Confirm.asp" method="post">
<table border="0" cellpadding="4" cellspacing="0">
<tr><td bgcolor="darkgray" align=left>
</td><td bgcolor="darkgray" align=left>
<font size="2"><b>File</b></font>
</td><td bgcolor="darkgray" align=left>
<font size="2"><b>Size (mb)</b></font>
</td></tr>
<%
'Display each file's name and size with a checkbox
Response.Write("<font size=5>Contents of: " & Folder & "<p>")
Dim FileSize
For Each FileItem In FolderContents
FileSize = Round(FileItem.Size / 1000000, 1) 'Converts file size into MB, rounds to tenth place
Response.Write("<tr><td bgcolor=lightgrey align=left>")
Response.Write("<input type=checkbox name=" & FileItem.Name & " value=" & FileItem.Name & ">")
Response.Write("</td><td bgcolor=lightgrey align=left>")
Response.Write(FileItem.Name) 'Displays file name
Response.Write("</td><td bgcolor=lightgrey align=right>")
Response.Write(FileSize) 'Displays file size in MB
Response.Write("</td></tr>")
Next
%>
</td></tr>
<tr><td colspan=3>
<input type="submit" value="Delete">
</td></tr>
</table>
</form>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------
Confirm.asp
<%@ Language="VBScript" %>
<html>
<head>
<title>Warning!</title>
<style type="text/css">
body, table {color:#000000; font-family:Verdana; font-size:11px}
</style>
</head>
<body background="/images/bground.gif" bgcolor="#ffffff" text="#000000" marginheight="0" topmargin="0">
<%
'Extract number of checked files
Dim Checked, FilesToDelete
Checked = 0 'Set number of checked to zero
For Each Checked In Request.Form
thisvalue = Request.Form(Checked)
If thisvalue = "on" Then
FilesToDelete = FilesToDelete + 1
End If
If FilesToDelete > 1 Then
FileNum = "files"
Else
FileNum = "file"
End If
Next
%>
<font color="#ff0000" size="6">Warning!</font><br>
<fotn size="3"><b>Are you sure that you want to delete the following <%= Response.Write(FileNum & "?") %></b></font>
<hr align="left" color="#000000" size="1" width="600" noshade>
<%
'Display all the files checked
Response.Write(thisvalue & "<br>")
%>
<br>
<input type="button" value="No, take me back" onClick="location='Music.asp'">
<input type="button" value="Yes, proceed" onClick="location='Delete.asp'">
</body>
</html>
-
Dec 3rd, 2000, 10:20 PM
#2
Frenzied Member
I usually give them all the same name and refer to them by index in the collection.
Are you trying to access the checkboxes on server side or client side as the syntax is different...
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 3rd, 2000, 10:34 PM
#3
But i want to delete the files that are coralated with the checked boxes...do you know what I mean? Only the ones that are checked get deleted. How would I set a collection up and then tie that into the orrigional files they represent?
-
Dec 4th, 2000, 10:53 AM
#4
Frenzied Member
I typically will put the unique identifier for the line into a hidden input tag and refer to it in the same manner (by index).
For me, that means putting the Primary Key into the input tag but you could just as easily put the filename in it.
If you have a group of the same tags repeated with a loop, you should give the tags the same name (same name for each row, not column of course) and refer to them by index. That also allows you to loop through the elements much easier than if they each had their own unique name.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 4th, 2000, 05:13 PM
#5
how do I access them by index?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|