Bläddra mellan sidor.

JavaScript

1 svar · 191 visningar · startad av SilvioF

Medlem sedan juni 2000547 inlägg
Trådstart#1

Halloj på er.

Har ett litet problem som jag hoppas få svar på här. Jag har en katalog med bilder som jag vill att folk ska kunna bläddra i. Saken är den att jag vill dela upp bilderna på X antal sidor med 5 bilder på varje.

<html>
	<head>
		<title>Hämtar bild...</title>
		<link rel="stylesheet" type="text/css" href="../../Css/public.css">
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<script language="JavaScript">  function doOk(returV) { window.close(); }
  function doCancel() { window.returnValue = 'avbryt'; window.close(); }
  function InsertTenPicture(StartAdr)
  {
    resultat = '130tom.gif;AAAA.gif;aktuella_fragor.gif;aktuellt_aktuellen.gif;aktuellt_evenemang.gif;aktuellt_inkommande.gif;aktuellt_pagaende.gif;aktuellt_pressmeddelande_arkiv.gif;aktuellt_upphandlingar.gif;aktuellt_vardbarometern.g if;';
    possX = resultat.indexOf(';', 0);
    Antalet = new Number(resultat.substring(0, possX).valueOf());
    resultat = resultat.substr(possX);
    possA = resultat.indexOf(';', 0);
    possB = resultat.indexOf(';', possA + 1);
    CounterA = 0;
    do {
      Filnamn = resultat.substring(possA + 1, possB);
      if (CounterA == 0) {
        document.all.Pict0.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict0.alt = Filnamn
      }
      if (CounterA == 1) {
        document.all.Pict1.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict1.alt = Filnamn
      }
      if (CounterA == 2) {
        document.all.Pict2.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict2.alt = Filnamn
      }
      if (CounterA == 3) {
        document.all.Pict3.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict3.alt = Filnamn
      }
      if (CounterA == 4) {
        document.all.Pict4.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict4.alt = Filnamn
      }
      if (CounterA == 5) {
        document.all.Pict5.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict5.alt = Filnamn
      }
      if (CounterA == 6) {
        document.all.Pict6.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict6.alt = Filnamn
      }
      if (CounterA == 7) {
        document.all.Pict7.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict7.alt = Filnamn
      }
      if (CounterA == 8) {
        document.all.Pict8.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict8.alt = Filnamn
      }
      if (CounterA == 9) {
        document.all.Pict9.src = '../../BildArkiv/menyer/' + Filnamn;
        document.all.Pict9.alt = Filnamn
      }
      CounterA = CounterA + 1;
      possA = possB;
      possB = resultat.indexOf(';',possA + 1);
    }
    while (possB > 0); {
      for (j = Antalet; j < 5; j ++) {
        if (j == 0) {
          document.all.Pict0.src = '../../BildArkiv/130tom.gif';
          document.all.Pict0.alt = '';
          document.all.Pict0.border = 0;
        }
        if (j == 1) {
          document.all.Pict1.src = '../../BildArkiv/130tom.gif';
          document.all.Pict1.alt = '';
          document.all.Pict1.border = 0;
        }
        if (j == 2) {
          document.all.Pict2.src = '../../BildArkiv/130tom.gif';
          document.all.Pict2.alt = '';
          document.all.Pict2.border = 0;
        }
        if (j == 3) {
          document.all.Pict3.src = '../../BildArkiv/130tom.gif';
          document.all.Pict3.alt = '';
          document.all.Pict3.border = 0;
        }
        if (j == 4) {
          document.all.Pict4.src = '../../BildArkiv/130tom.gif';
          document.all.Pict4.alt = '';
          document.all.Pict4.border = 0;
        }
        if (j == 5) {
          document.all.Pict5.src = '../../BildArkiv/130tom.gif';
          document.all.Pict5.alt = '';
          document.all.Pict5.border = 0;
        }
        if (j == 6) {
          document.all.Pict6.src = '../../BildArkiv/130tom.gif';
          document.all.Pict6.alt = '';
          document.all.Pict6.border = 0;
        }
        if (j == 7) {
          document.all.Pict7.src = '../../BildArkiv/130tom.gif';
          document.all.Pict7.alt = '';
          document.all.Pict7.border = 0;
        }
        if (j == 8) {
          document.all.Pict8.src = '../../BildArkiv/130tom.gif';
          document.all.Pict8.alt = '';
          document.all.Pict8.border = 0;
        }
        if (j == 9) {
          document.all.Pict9.src = '../../BildArkiv/130tom.gif';
          document.all.Pict9.alt = '';
          document.all.Pict9.border = 0;
        }
      }
    }
  }
</script>
	</head>
	<body topmargin="0" marginheight="0" marginwidth="0" bgcolor="ffffff" onLoad="InsertTenPicture(document.all.FirstPict.value);">
		<table align="center" border="0" cellspacing="0" cellpadding="0" width="360" height="240">
			<tr>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict0" style="cursor:hand" border="1">
				</td>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict1" style="cursor:hand" border="1">
				</td>
			</tr>
			<tr>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict2" style="cursor:hand" border="1">
				</td>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict3" style="cursor:hand" border="1">
				</td>
			</tr>
			<tr>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict4" style="cursor:hand" border="1">
				</td>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict5" style="cursor:hand" border="1">
				</td>
			</tr>
			<tr>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict6" style="cursor:hand" border="1">
				</td>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict7" style="cursor:hand" border="1">
				</td>
			</tr>
			<tr>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict8" style="cursor:hand" border="1">
				</td>
				<td align="left" width="200">
					<img onClick="doOk(this.alt);" id="Pict9" style="cursor:hand" border="1">
				</td>
			</tr>
		</table>
		<br>
		<input type="hidden" name="FirstPict" id="FirstPict" value="0">
		<table align="center" border="0" cellspacing="0" cellpadding="0" width="360" height="20">
			<tr>
				<td align="left" width="200">
					<div id="MindreKnapp" style="visibility:hidden;">
						<input onClick="
							{
								NumberOfPicture = new Number(document.all.FirstPict.value.valueOf());
								document.all.MeraKnapp.style.visibility = 'visible';
								if (NumberOfPicture > 0)
								{
									document.all.FirstPict.value = NumberOfPicture - 5;
									InsertTenPicture(document.all.FirstPict.value);
									if (NumberOfPicture == 5)
									{
										document.all.MindreKnapp.style.visibility = 'hidden';
									}
								} else {
									alert('Detta är de första bilderna i bildarkivet.');
								}
							}
							" type="button" value="Föregående 5 bilder" class="button" style="width:150px;">
					</div>
				</td>
				<td align="left" width="200">
					<div id="MeraKnapp" style="visibility:visible;">
						<input onClick="
							{
								document.all.MindreKnapp.style.visibility = 'visible';
								NumberOfPicture = new Number(document.all.FirstPict.value);
								document.all.FirstPict.value = NumberOfPicture.value + 5;
								InsertTenPicture(document.all.FirstPict.value);
alert(NumberOfPicture.value);
							}
							" type="button" value="Nästa 5 bilder" class="button" style="width:150px;">
					</div>
				</td>
			</tr>
		</table>
	</body>
</html>

Problemet med koden är att när man klickar på "Nästa 5 bilder" så sätts det inte in rätt värde i det gömda fältet "FirstPict". Någon som ser felet? Det skulle hjälpa mig oerhört i så fall.

Medlem sedan juni 2000547 inlägg
#2

Skrev visst lite fel i koden nu. Ignorera bara allting som sätter Pict5 och framåt samt img-taggarna som heter Pict5 och framåt.

275 ms totalt · 4 externa anrop · v20260731065814-full.d34c6d5a
125 ms — deklarationer (db)
0 ms — hämta statistik (cache)
147 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)