Jag använder nedanståde kod och den listar alla filer i den aktuella katalogen som vanliga länkar, nu vill jag att filerna ska listas i en dropdown istället, hur gör jag? Där du skriver ut din länk, ändra till Tack, det funkade. Nu vill jag dock ha så att när man klickar på knappen så visas filen i framen som heter hoger. Efter lite konsultation på IRC med en person så fick jag fram en lösning, här är den:Fillista i dropdown
<code>
<%
Dim objFSO, objFile
Dim sMapPath, objFolder
'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("./.") ' this means the current directory
'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified
For Each objFile in objFolder.Files
Response.Write "<font size=2 face=Verdana><a target=hoger href="""&objFile.Name&""">"
Response.write objFile.Name
Response.write "</a></font><br>"
Next ' Loop back
' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
%>
</code>Sv: Fillista i dropdown
<code>
Response.write "<select Name=""FilNamn"">" '''''''''''''''' Vi behöver bara en selectsats, lägg den utanför loopen
For Each objFile in objFolder.Files
Response.Write "<option value=""" & objFile.Name & """>"& objFile.Name & ">"
Next ''Flytta ett steg
Response.Write "</select>"
<code>
Jag tror att jag fick att fnuttar på rätt ställen.
//Anna-KarinSv: Fillista i dropdown
Det här är koden jag har nu, och då visas bilden i samma frame.
<codeasp>
<%
Dim objFSO, objFile
Dim sMapPath, objFolder
''Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
''Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("./.") '' this means the current directory
''Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
'' Then for each file in the object we loop through and print the file and when it was last modified
''For Each objFile in objFolder.Files
Response.Write "<FORM NAME=""menyn"">"
Response.Write "<SELECT NAME=""meny"">"
For Each objFile in objFolder.Files
Response.Write "<option value=""" & objFile.Name & """>"& objFile.Name & ""
Next
Response.Write "</select>"
'' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
Response.Write "<INPUT TYPE=""button"" VALUE=""Show!"" onClick=""if (document.menyn.meny.selectedIndex){document.location.href=document.menyn.meny.options[document.menyn.meny.selectedIndex].value;}""></FORM>"
%>
</code>Sv: Fillista i dropdown
<codeasp
<%
Dim objFSO, objFile
Dim sMapPath, objFolder
''Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
''Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("./.") '' this means the current directory
''Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
'' Then for each file in the object we loop through and print the file and when it was last modified
''For Each objFile in objFolder.Files
Response.Write "<FORM NAME=""menyn"">"
Response.Write "<SELECT NAME=""meny"">"
For Each objFile in objFolder.Files
Response.Write "<option value=""" & objFile.Name & """>"& objFile.Name & ""
Next
Response.Write "</select>"
'' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
Response.Write "<INPUT TYPE=""button"" VALUE=""Show!"" onClick=""if (document.menyn.meny.selectedIndex){top.hoger.location.href=document.menyn.meny.options[document.menyn.meny.selectedIndex].value;}""></FORM>"
%>
</code>