webForumDet fria alternativet

lista endast .jpg och .gif, inte .asp?

ASP

4 svar · 216 visningar · startad av tank82

Medlem sedan feb. 2003210 inlägg
Frågan#1

Hejsan!
Går det att göra så endast .jpg och .gif filer visas? för nu så ser man även .asp osv och det vill jag inte. :q

<%
Antal = 8
MappNamn = "bilder"
%>

<script language="javaScript">
function Show(filename,winTitle) 
{
    var myImage = new Image();
    myImage.src=filename;
    properties='height=10,width=10';
    var imgWindow = window.open('','',properties);
    
    html = '<html>';
    html += '<head>';
    html += '<title>'+winTitle+'</title>';
    html += '</head>';
    html += '<body topmargin="0" marginheight="0" leftmargin="0" marginwidth="0">';
    html += '<img src="'+myImage.src+'" onLoad="resizeTo(document.bild.width+10,document.bild.height+29);" name="bild" OnClick="self.close();">';
    html += '</body>';
    html += '</html>';
    
    imgWindow.document.write(html);
}
</script>

<%Set Mappkoll = Server.CreateObject("Scripting.FileSystemObject")
Set Mapp = Mappkoll.GetFolder(Server.MapPath(MappNamn))

Set MyDrive = Mapp.subFolders%>

<table width="100%" border="0">
<tr>
   <td><big><big><big>Foto!</font></big></big></big></td>
</tr>
<tr>
   <td><select style="width: 100px; name="meny" onChange="self.location.href=this.options[this.selectedIndex].value;">
       <option value="">» VÄLJ KATEGORI
       <%For Each Folder in MyDrive%>
           <option value="index.asp?avdelning=bilder&visa=bilder&mapp=<%=MappNamn%>/<%=Folder.Name%>">» <%=Folder.Name%><br>
       <%Next%>
       </select><br><hr noshade size="1" color="#000000"></td>
</tr>
</table>

<%If Request.QueryString("visa") = "bilder" Then

MappNamn = Request.QueryString("mapp")

Set Mappkoll = Server.CreateObject("Scripting.FileSystemObject")
Set Mapp = Mappkoll.GetFolder(Server.MapPath(MappNamn))%>

<table width="100%" border="0">

<%If Mapp.Files.Count = 0 Then%>
       <tr> 
           <td>Inga bilder</td> 
       </tr> 
<%Else
x=0
For Each File In Mapp.Files
If x = Antal Then
  Response.Write "<tr>"
  x = 0
End If%>
   <td width="16%" valign="top"><a href="javascript:Show('<%=MappNamn%>/<%=File.Name%>','<%=File.Name%>')"><img src="<%=MappNamn%>/<%=File.Name%>" width="86" height="86" border="1" alt="<%=File.Name%>"></a></td>
<%X=X+1
Next
If x Mod Antal <> 0 Then
   For i = 1 To Antal - x Mod Antal%>
        <td width="16%">&nbsp;</td>
   <%Next
  Response.Write "</tr>"
End If
End If%>
</table>

<%End If%>
Medlem sedan juli 20011 084 inlägg
#2
filetype= Right(File.Name,Len(File.Name)-inStrRev(File.Name,"."))

if(filetype = "gif" OR filetype= "jpg") Then ...
Medlem sedan feb. 2003210 inlägg
#3

hmm ok men var lägger jag in detta? :)
Jag har provat på lite olika sätt men får det ej att fungera..

Medlem sedan mars 20015 287 inlägg
#4
<%Set Mappkoll = Server.CreateObject("Scripting.FileSystemObject")
Set Mapp = Mappkoll.GetFolder(Server.MapPath(MappNamn))

Set MyDrive = Mapp.subFolders%>

<table width="100%" border="0">
<tr>
   <td><big><big><big>Foto!</font></big></big></big></td>
</tr>
<tr>
   <td><select style="width: 100px; name="meny" onChange="self.location.href=this.options[this.selectedIndex].value;">
       <option value="">» VÄLJ KATEGORI
       <%For Each Folder in MyDrive%>
           <option value="index.asp?avdelning=bilder&visa=bilder&mapp=<%=MappNamn%>/<%=Folder.Name%>">» <%=Folder.Name%><br>
       <%Next%>
       </select><br><hr noshade size="1" color="#000000"></td>
</tr>
</table>

<%If Request.QueryString("visa") = "bilder" Then

MappNamn = Request.QueryString("mapp")

Set Mappkoll = Server.CreateObject("Scripting.FileSystemObject")
Set Mapp = Mappkoll.GetFolder(Server.MapPath(MappNamn))%>

<table width="100%" border="0">

<%If Mapp.Files.Count = 0 Then%>
       <tr> 
           <td>Inga bilder</td> 
       </tr> 
<%Else
x=0
For Each File In Mapp.Files

	filetype= Right(File.Name,Len(File.Name)-inStrRev(File.Name,"."))
	If(filetype = "gif" OR filetype= "jpg") Then

		If x = Antal Then
  			Response.Write "<tr>"
  			x = 0
		End If
%>
   <td width="16%" valign="top"><a href="java script:Show('<%=MappNamn%>/<%=File.Name%>','<%=File.Name%>')"><img src="<%=MappNamn%>/<%=File.Name%>" width="86" height="86" border="1" alt="<%=File.Name%>"></a></td>
<%
	X=X+1
	End If
Next
If x Mod Antal <> 0 Then
   For i = 1 To Antal - x Mod Antal%>
        <td width="16%"> </td>
   <%Next
  Response.Write "</tr>"
End If
End If
%>
</table>

<%End If%>
Medlem sedan feb. 2003210 inlägg
#5

Fan solbulle du är en klippa :)

263 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
135 ms — deklarationer (db)
0 ms — hämta statistik (cache)
125 ms — hämta tråd, inlägg och bilagor (db)
121 ms — ändringar (db)