Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-28-2006, 10:13 AM   #1 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Image Loop

Upon achieving the following code to display images from a folder, in ascending order of number. is there anyway to display all images in the folder upon the page loading? As at the moment this can only be done through a button being clicked.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body onload="show()">
<script type="text/javascript">
var images = new Array();
var path = "media/";
var filename = 0;

function show()
{
  images[images.length]='<a href="'+path+filename+'.wmv"</a><img src="'+path+filename+'.jpg">'
  document.getElementById('pictures').innerHTML=images
  filename++;
}

</script>
<input type="submit" name="Submit" onclick="show()" value="Submit">
<div style="color=white;" id="pictures"></div>
</body>
</html>
Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 08-28-2006, 12:07 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Don't you have to define show() before you use it in the onload statement?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 08-28-2006, 12:44 PM   #3 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
I have done this, the first image gets displayed, but is there anyway i can make a loop to make the rest of the image in the folder appear for example: image 1 and above.

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 08-28-2006, 05:18 PM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Code:
function show()
{
  for( var i = 0; i < images.length; i++ ){
    images[i]='<a href="'+path+filename+'.wmv"</a><imgsrc="'+path+filename+'.jpg">'
    document.getElementById('pictures').innerHTML=images
  }
}
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 08-28-2006, 06:02 PM   #5 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I should have read the rest of your code, looks like the loop init should actually read
Code:
for (var i = 0; i < numImages; i++){
    images[i]='<a href="'+path+filename+'.wmv"</a><imgsrc="'+path+filename+'.jpg">'
    document.getElementById('pictures').innerHTML=images;
  filename++;
}
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 08-28-2006, 11:52 PM   #6 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Image Loop

teknomage1,

The code you sent me doen't work, is it due to the fact that image.length is always equal to filename (number of images being displayed, starting @ zero).

How can i change it so filename is one step behind images.length until all images within the folder have been displayed.

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 08-28-2006, 11:53 PM   #7 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Image Loop

teknomage1,

The code you sent me doen't work, is it due to the fact that image.length is always equal to filename (number of images being displayed, starting @ zero).

How can it be changed so filename is one step behind images.length until all images within the folder have been displayed.

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 08-29-2006, 06:38 AM   #8 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,695
redhead is on a distinguished road
you can't, because the images you're trying to load is placed server-side, and the script running to decide how many images you have is located client side..
So it will only know of the one image at hand, not how many there might be available.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 08-29-2006, 12:25 PM   #9 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
redhead's correct, maybe you should switch to a serrver side language, such as php or perl. Alternatively if you wish to continue down this road, maybe you should make a text entry box, so you can tell it how many images to load.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
switch a .gif image in asp.net datagrid rikb53 MS Technologies ( ASP, VB, C#, .NET ) 0 02-17-2006 12:39 PM
Stationary Image joehouse HTML, XML, Javascript, AJAX 4 08-05-2005 07:03 PM
Breaking out of external loop agh Standard C, C++ 7 04-30-2003 08:03 PM
the endless loop loop loop loop loop loop ... abc123 All Other Coding Languages 2 08-14-2002 03:43 PM


All times are GMT -8. The time now is 10:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting