---
title: "Får inte till att bläddra mellan bilder!"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/135147-får-inte-till-att-bläddra-mellan-bilder"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "invalido"
published: "2005-10-02T21:26:55.000Z"
updated: "2005-10-17T06:03:58.000Z"
replies: 28
views: 1259
page: 1
pages: 2
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/135147-får-inte-till-att-bläddra-mellan-bilder"
---

# Får inte till att bläddra mellan bilder!

_Sida 1 av 2._

## #1 — invalido, 2005-10-02T21:26Z

Jag skulle vilja ha hjälp med ett skript så att jag kan bläddra mellan bilder. Jag har ett .ASP skript som består av en fil som heter photoalbum.asp som visar thumbnails av bilderna och en annan som heter showpic.asp som fungerar som popup fil. Bilderna laddas upp automatiskt genom att man laddar upp hela mappen till den underkategorin som de båda .asp filerna ligger. Hur ska ajg göra?

Så här ser koden ut på pop-up filen:

var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) \>= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers\[0\].document.images\[0\].width;
window.innerHeight = document.layers\[0\].document.images\[0\].height;
}
if (isIE4) {
window.resizeTo(400, 300);
width = (400 - (document.body.clientWidth -  document.images\[0\].width)) + 25;
height = (300 - (document.body.clientHeight -  document.images\[0\].height)) + 55;
window.resizeTo(width, height);
   }
}
//  End --\>
\</script\>

\</head\>

\<BODY onLoad="fitWindowSize()"\>

\<center\>
\<%
ShowPic = request("ShowPic")
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "\<img src='" & ShowPic & "' border=2\>\<BR\>"
response.write "\<font size='2'\>\<a href='JavaScript:onClick= window.close()'\>\<font color='#FFFFBE'\>Close Window\</font\>\</A\>\</font\>"
%\>
\</center\>
\</body\>
\</html\>

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

## #2 — emission, 2005-10-03T06:57Z

Vad är problemet?

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

## #3 — invalido, 2005-10-03T11:50Z

jag vill kunna lägga till en meny "föregående/nästa" som automatiskt hoppar till samma bild. Utan att behöva namnge bilderna!

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

## #4 — invalido, 2005-10-03T18:01Z

mena nästa bild.. inte samma

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

## #5 — emission, 2005-10-03T19:45Z

Hur ser koden ut som listar filerna?

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

## #6 — invalido, 2005-10-03T20:27Z

men det finns en fil som e själva fotoalbumet men som bara visar thumbnails av bilderna. sen finns det en som fungerar som pop-up och det e den jag vill lägga in "nästa och föregående" på. vilken kod vill du ha? För själva uppladdningen av bilderna sker automatiskt!

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

## #7 — emission, 2005-10-03T22:07Z

Jag vill se den som visar thumbnails :)

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

## #8 — invalido, 2005-10-04T05:08Z

\<%

' PhotoAlbum

Dim CurFile, PopFileShowSub, ShowPic, PictureNo
Dim strPathInfo, strPhysicalPath

Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages, intPage, strPicArray()
intPicsPerRow  = 3
intPicsPerPage = 12

intPage = CInt(Request.QueryString("Page"))
If intPage = 0 Then
	intPage = 1
End If

CurFile = "PhotoAlbum.asp"
PopFile = "ShowPicture.asp"
%\>
\<link rel="stylesheet" type="text/css" href="style.css"\>
\<script language="JavaScript"\>
\<!--
function jumppage(sel) 
{
  var i = sel.selectedIndex
  self.location.href = sel.options*.value
}
// --\>
\</script\>
\<script language="JavaScript"\>
\<!-- hide from JavaScript-challenged browsers
function openGalleryWindow(url) {
	if (document.all)
		var xMax = screen.width, yMax = screen.height;
	else
		if (document.layers)
			var xMax = window.outerWidth, yMax = window.outerHeight;
		else
			var xMax = 800, yMax=600;
	var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
	var xOffset = 100, yOffset = 100;

	popupWin = window.open(url,'new_page','width=700,height=535,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=auto,toolbars=no,menubar=no,resizable=yes')
}
// done hiding --\>
\</script\>

\<style type="text/css"\>
\<!--
body {
	background-color: #000000;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}

\--\>
\</style\>\<center\>
\<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%" id="AutoNumber1"\>
\<tr\>

\<td align="center" width="25%"\>
  \<form action=\<%=PopFile%\> method="POST"\>
  \<font face="\<%= strDefaultFontFace %\>" size="\<% =strFooterFontSize %\>" color="\<% =strBaseFontColor %\>"\>\<span class="style1"\>Händelser:\</span\>
  \<select name="go" onChange="jumppage(this);" size=1\>
  \<% 
  ShowSub = request("ShowSub")
  ShowPic = request("ShowPic")
  strPathInfo = Request.ServerVariables("PATH_INFO")
  strPhysicalPath = Server.MapPath(strPathInfo)
 
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.GetFile(strPhysicalPath)
  Set objFolder = objFile.ParentFolder
  Set objFolderContents = objFolder.Files
  For each Folder in objFolder.SubFolders
  	If Left(Folder.Name,1)\<\>"\_" Then
	  	Response.write "\<option "
	  	If ShowSub=Folder.Name Then
	  		Response.Write "selected "
	  	End if
	  	Response.Write"value='" & CurFile & "?ShowSub="
	  	Response.Write(Replace(Folder.Name, " ", "%20"))
	  	response.write "'\>"
	  	Response.Write(Folder.Name & "\</option\>")
	  	If ShowSub \<= " " Then
	  	  ShowSub = Folder.Name
		End if
  	End if
  Next 
  Set objFSO = Nothing
  %\>
  \</select\>\</h3\>
  \</form\>
  \</td\>
\</tr\>
\</table\>

\<%
If ShowPic \> " " then
  ShowPic = Replace(ShowPic, " ", "%5")
  Response.Write "\<a href='JavaScript:history.go(-1)'\>\<img src='" & ShowPic & "'\>\<BR\>\<BR\>\<font face=""verdana"" size=""1""\>\<b\>Go Back\</b\>\</a\>"
Else
%\>
  \<table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%" id="AutoNumber1"\>
  \<tr\>
  \<%
  strPhysicalPath = Server.MapPath(".\\" & ShowSub)
  If ShowSub \> " " then
    ShowSub = Replace(ShowSub, " ", "%20")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(strPhysicalPath)
    Set objFolderContents = objFolder.Files

	 'Get the number of pictures in the subdirectory 
	 intTotPics = 0
    For Each objFileItem in objFolderContents
		If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
			intTotPics = intTotPics + 1
		End if
    Next

	'Get the total number of pages in the subdirectory 
	If (intTotPics/intPicsPerPage) = (int(intTotPics/intPicsPerPage)) Then
		intTotPages = int(intTotPics/intPicsPerPage)
	Else
		intTotPages = int(intTotPics/intPicsPerPage)+1
	End If
	Redim strPicArray(2,intTotPics)

	'Store picture file names in an array
	x = 0
	For Each objFileItem in objFolderContents
		If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
			strPicArray(0,x) = objFileItem.Name
			strPicArray(1,x) = Cstr(int(x/intPicsPerPage)+1)
			x = x + 1
		End if
	Next

	'Determine if there are multiple pages and if so, display page numbers.
	If intTotPages \> 1 Then
		Response.Write "\<td colspan='" & intPicsPerRow & "' align='center'\>\<font face='Verdana,Arial' size='1'\>Page:&nbsp;&nbsp;&nbsp;"
		For x = 1 to intTotPages
			If x = intPage Then
				Response.Write "\</font\>\<font face='Arial' size='2'\>" & x & "\</font\>\<font face='Arial' size='1'\>&nbsp;&nbsp;&nbsp;&nbsp;"
			Else
				Response.Write "\<a href='PhotoAlbum.asp?Page=" & x & "&ShowSub=" & ShowSub & "'\>" & x & "\</a\>&nbsp;&nbsp;&nbsp;&nbsp;"
			End If
		Next
		Response.Write "\</font\>\</td\>"
		Response.Write "\</tr\>\<tr\>\<td\>&nbsp;\</td\>\</tr\>\<tr\>"
	End If

	For x = 0 to UBound(strPicArray,2)-1
	If CInt(strPicArray(1,x)) = intPage Then
     ShowPic = Replace(strPicArray(0,x), " ", "%20")
   	  Response.write "\<td align='center' width='25%'\>\<a href=""Javascript:openGalleryWindow('" & PopFile & "?ShowPic=" & ShowSub & "/" & ShowPic & "')"""
	  Response.write "\<br\>"
	  Response.Write("\<img src='" & ShowSub & "/" & strPicArray(0,x) & "' width=100\> ") 

	  Response.write "\</a\>\</td\>" & vbcrlf

	  PictureNo = PictureNo + 1
	  If PictureNo=intPicsPerRow Then
		  Response.write "\</tr\>\<tr\>"
		  PictureNo = 0
	  End if
	End If
	Next

    Set objFSO = Nothing
  End if
  %\>
  \</tr\>
  \</table\>
\<%
End if
%\>
\</center\>
\</html\>*

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

## #9 — @nders, 2005-10-04T05:48Z

Det vore bra om du använde \[kod\]-taggarna när du postar kod, så blir koden lättare att läsa. :)

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

## #10 — invalido, 2005-10-04T21:44Z

men kan ni inte lägga till ett skript så att man får till d?

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

## #11 — emission, 2005-10-04T22:28Z

> **invalido skrev:**
>
> men kan ni inte lägga till ett skript så att man får till d?

Vad menar du?

Snabbfixat med lite klipp och klistra. Fungerar **kanske**

```
<%

' PhotoAlbum

Dim CurFile, PopFileShowSub, ShowPic, PictureNo
Dim strPathInfo, strPhysicalPath

Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages, intPage, strPicArray()
intPicsPerRow = 3
intPicsPerPage = 12

intPage = CInt(Request.QueryString("Page"))
If intPage = 0 Then
intPage = 1
End If

CurFile = "PhotoAlbum.asp"
PopFile = "ShowPicture.asp"
%>
<link rel="stylesheet" type="text/css" href="style.css">
<script language="JavaScript">
<!--
function jumppage(sel)
{
var i = sel.selectedIndex
self.location.href = sel.options[i].value
}
// -->
</script>
<script language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openGalleryWindow(url) {
if (document.all)
var xMax = screen.width, yMax = screen.height;
else
if (document.layers)
var xMax = window.outerWidth, yMax = window.outerHeight;
else
var xMax = 800, yMax=600;
var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
var xOffset = 100, yOffset = 100;

popupWin = window.open(url,'new_page','width=700,height=535,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=auto,toolbars=no,menubar=no,resizable=yes')
}
// done hiding -->
</script>

<style type="text/css">
<!--
body {
background-color: #000000;
}
.style1 {
color: #FFFFFF;
font-weight: bold;
}

-->
</style><center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%" id="AutoNumber1">
<tr>

<td align="center" width="25%">
<form action=<%=PopFile%> method="POST">
<font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>" color="<% =strBaseFontColor %>"><span class="style1">Händelser:</span>
<select name="go" onChange="jumppage(this);" size=1>
<%
ShowSub = request("ShowSub")
ShowPic = request("ShowPic")
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
For each Folder in objFolder.SubFolders
If Left(Folder.Name,1)<>"_" Then
Response.write "<option "
If ShowSub=Folder.Name Then
Response.Write "selected "
End if
Response.Write"value='" & CurFile & "?ShowSub="
Response.Write(Replace(Folder.Name, " ", "%20"))
response.write "'>"
Response.Write(Folder.Name & "</option>")
If ShowSub <= " " Then
ShowSub = Folder.Name
End if
End if
Next
Set objFSO = Nothing
%>
</select></h3>
</form>
</td>
</tr>
</table>

<%
If ShowPic > " " then
ShowPic = Replace(ShowPic, " ", "%5")
Response.Write "<a href='javascript:history.go(-1)'><img src='" & ShowPic & "'><BR><BR><font face=""verdana"" size=""1""><b>Go Back</b></a>"
Else
%>
<table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" bordercolor="#FFFFFF" width="100%" id="AutoNumber1">
<tr>
<%
strPhysicalPath = Server.MapPath(".\" & ShowSub)
If ShowSub > " " then
ShowSub = Replace(ShowSub, " ", "%20")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
Set objFolderContents = objFolder.Files

'Get the number of pictures in the subdirectory
intTotPics = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
intTotPics = intTotPics + 1
End if
Next

'Get the total number of pages in the subdirectory
If (intTotPics/intPicsPerPage) = (int(intTotPics/intPicsPerPage)) Then
intTotPages = int(intTotPics/intPicsPerPage)
Else
intTotPages = int(intTotPics/intPicsPerPage)+1
End If
Redim strPicArray(2,intTotPics)

'Store picture file names in an array
x = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
strPicArray(0,x) = objFileItem.Name
strPicArray(1,x) = Cstr(int(x/intPicsPerPage)+1)
x = x + 1
End if
Next

'Determine if there are multiple pages and if so, display page numbers.
If intTotPages > 1 Then
Response.Write "<td colspan='" & intPicsPerRow & "' align='center'><font face='Verdana,Arial' size='1'>Page:&nbsp;&nbsp;&nbsp;"
For x = 1 to intTotPages
If x = intPage Then
Response.Write "</font><font face='Arial' size='2'>" & x & "</font><font face='Arial' size='1'>&nbsp;&nbsp;&nbsp;&nbsp;"
Else
Response.Write "<a href='PhotoAlbum.asp?Page=" & x & "&ShowSub=" & ShowSub & "'>" & x & "</a>&nbsp;&nbsp;&nbsp;&nbsp;"
End If
Next
Response.Write "</font></td>"
Response.Write "</tr><tr><td>&nbsp;</td></tr><tr>"
End If

For x = 0 to UBound(strPicArray,2)-1
If CInt(strPicArray(1,x)) = intPage Then
ShowPic = Replace(strPicArray(0,x), " ", "%20")
Response.write "<td align='center' width='25%'><a href=""javascript:openGalleryWindow('" & PopFile & "?ShowSub=" & ShowSub & "&px=" & x & "')"""
Response.write "<br>"
Response.Write("<img src='" & ShowSub & "/" & strPicArray(0,x) & "' width=100> ")

Response.write "</a></td>" & vbcrlf

PictureNo = PictureNo + 1
If PictureNo=intPicsPerRow Then
Response.write "</tr><tr>"
PictureNo = 0
End if
End If
Next

Set objFSO = Nothing
End if
%>
</tr>
</table>
<%
End if
%>
</center>
</html>
```

```
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(400, 300);
width = (400 - (document.body.clientWidth - document.images[0].width)) + 25;
height = (300 - (document.body.clientHeight - document.images[0].height)) + 55;
window.resizeTo(width, height);
}
}
// End -->
</script>

</head>

<BODY onLoad="fitWindowSize()">

<center>
<%
ShowSub = request("ShowSub")
strPhysicalPath = Server.MapPath(".\" & ShowSub)
px=cInt(request.querystring("px"))
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
Set objFolderContents = objFolder.Files
strFileName=""
x = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
	if x=px then strFileName=objFileItem.Name
	x = x + 1
End if
Next

if px>0 then
   Response.Write " <a href=""" & Request.ServerVariables("SCRIPT_PATH") & "?px=" & px-1 & "&ShowSub=" & Server.UrlEncode(ShowSub) & """>Previous</a>"
end if
if px<(x-1) then
   Response.Write " <a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?px=" & px+1 & "&ShowSub=" & Server.UrlEncode(ShowSub) & """>Next</a>"
end if
ShowPic=strFileName
if ShowSub<>"" then ShowPic=Server.URLEncode(ShowSub) & "/" & ShowPic
Response.Write "<img src='" & ShowPic & "' border=2><BR>"
response.write "<font size='2'><a href='javascript:onClick= window.close()'><font color='#FFFFBE'>Close Window</font></A></font>"
%>
</center>
</body>
</html>
```

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

## #12 — invalido, 2005-10-05T05:19Z

fungerar säker det där med nästa och föregående.. men nu får jag inte upp pop-upen när ajg klickar på en bild! :S

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

## #13 — invalido, 2005-10-07T22:51Z

kan du hitta nått fel med filen?

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

## #14 — invalido, 2005-10-07T22:51Z

eller skriptet menar ajg!

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

## #15 — emission, 2005-10-08T00:02Z

Provkörde nu och det fungerar toppen, men tänk på att ingen av kodexemplen var kompletta HTML-dokument. Det saknas en del i toppen.

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

## #16 — invalido, 2005-10-08T09:27Z

jo men jag ersatte bara den del som du hade modifierat. Får itne upp pop-up filen. När ajg bara ersatte den filen utan photoalbums filen så funkade pop-upen men visade ingen bild!

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

## #17 — emission, 2005-10-08T10:36Z

Felmeddelande?

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

## #18 — invalido, 2005-10-08T12:40Z

blir abra ett litet kryss

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

## #19 — emission, 2005-10-08T14:02Z

Hur blir själva img-href:en?

Gjorde en liten ändring (SCRIPT_NAME) i det undre skriptet.

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

## #20 — invalido, 2005-10-09T14:55Z

vad menar du? är inte alltför insatt :S men bilderna ligger i samma mapp som själva skripten i olika mappar!

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/135147-får-inte-till-att-bläddra-mellan-bilder  
Nästa sida: https://www.webforum.nu/amne/asp/135147-får-inte-till-att-bläddra-mellan-bilder/page2.md
