---
title: "lista endast .jpg och .gif, inte .asp?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/83904-lista-endast-jpg-och-gif-inte-asp"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "tank82"
published: "2003-08-10T08:59:22.000Z"
updated: "2003-08-10T21:08:43.000Z"
replies: 4
views: 222
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/83904-lista-endast-jpg-och-gif-inte-asp"
---

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

## #1 — tank82, 2003-08-10T08:59Z

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%>
```

Permalänk: https://www.webforum.nu/p/83904

## #2 — mozilla, 2003-08-10T10:04Z

```
filetype= Right(File.Name,Len(File.Name)-inStrRev(File.Name,"."))

if(filetype = "gif" OR filetype= "jpg") Then ...
```

Permalänk: https://www.webforum.nu/p/1132819

## #3 — tank82, 2003-08-10T14:04Z

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

Permalänk: https://www.webforum.nu/p/1132931

## #4 — solbulle, 2003-08-10T18:14Z

```
<%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%>
```

Permalänk: https://www.webforum.nu/p/1133051

## #5 — tank82, 2003-08-10T21:08Z

Fan solbulle du är en klippa :)

Permalänk: https://www.webforum.nu/p/1133157

---

Tråden på webben: https://www.webforum.nu/amne/asp/83904-lista-endast-jpg-och-gif-inte-asp
