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-20-2006, 07:12 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
Load Images from a folder

Hello Every,

Is there anybody who could point me in the right direction to load images dynamically from a folder, and display on the screen.

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 08-20-2006, 07:15 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
do you have a server-side language available to you? if your server supports PHP, check out readdir.

you can not do this with client side languages (html/javascript) alone.
__________________
Mike
sde is offline   Reply With Quote
Old 08-20-2006, 07:26 AM   #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
Load Images from a folder

sde,

It is possable in Javascript, as i have acheived it, only an error message displays at execution. This reads as follows:
  • Stack overflow at line: 0
Can you/anybody tell me why this is? See code below.
I would prefer to do it in Javascript rathewr than PHP as it will only be used on my machine not uploaded to a server.

Code:
<script type="text/javascript">
function play(media) {
  var promptStr = 'Playing:'+media.substring(media.lastIndexOf('/')+1)+'<br>';
  var objectStr = '<object classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95"'+'type="application/x-oleobject" width="412" height="276">'+
  '<param name="showControls" value="false">'+
  '<param name="fileName" value="'+media+'">'+
  '<embed type="application/x-mplayer2" width="320" height="285"'+'showcontrols="true" src="'+media+'"><\/embed>'+
  '<\/object>'   
  document.getElementById('mediaplayer').innerHTML=promptStr+objectStr;
}
var myImages = new Array();
var i=1;
var dir = "images/"
function loadNext(thePic) {
  var theSrc=thePic.src;
  var w=thePic.width;
  var h=thePic.height;
  if (w<h) { // portrait
    w=54;
    h=74;
  }
  else { // landscape
    w=74;
    h=54;
  }
  myImages[myImages.length]='<img src="'+theSrc+'" width="'+w+'" height="'+h+'" border="0">';
  document.loadImage.src=dir+(i++)+'.gif'
}
function show() {
  window.status='Done'
  var text = '';
  text +='<table border="0">'

  for (var i=0;i<myImages.length;) {
    text += '<tr>'
    for (var j=0;j<3 && i<myImages.length;j++) {
      text +='<td><a href="'+dir+i+'.wmv" onClick="play(\''+dir+i+'.wmv\'); return false">'+
      myImages[i]+'</a></td>';
      i++;
    }
    text += '</tr>'
  }
  document.getElementById('allLinks').innerHTML=text;
}
</script>

<div id="allLinks"></div>
<div id="allImages" style="display:none">
<img
src="images/0.gif" name="loadImage" width="150" height="108" onError="show()" onLoad="loadNext(this)">
</div>
<ul id="menu">
  <li><a onclick="play('box1.wmv');return false" href="">Source 1</a></li>
  <li><a onclick="play('1.mpg');return false" href="">Source 2</a></li>
  <li><a onclick="play(this.href);return false" href="">Source 3</a></li>

</ul>
<div id="mediaplayer"></div>
Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 08-20-2006, 08:28 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
it is not possible. (reading a server directory with javascript without the combined use of server-side languages)

maybe that java applet you are embedding is doing something different, but java is not javascript. if you are using a java applet to do the directory browsing somehow, you need to refer to the documentation from the author.
__________________
Mike
sde is offline   Reply With Quote
Old 08-20-2006, 09:04 AM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,711
redhead is on a distinguished road
Well your version isn't dynamicaly loading what ever pic is found in the directory.. It assumes theres alot of images all called 1.gif, 2.gif, 3.gif ..., N.gif
Yet the N isn't specified, so if you have 5 images, and you keep on pressing <next> it will eventualy display "Image not found", not stop when the end of your available images is reached.

As to your error, I havn't looked too much on the code, so at this point I have no solution for you.
__________________
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-22-2006, 02:03 AM   #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
Load images from a folder

Redhead & sde,

Is there anyway of recoding this in order for it to successfullly work in IE with no wanring messages.

Also for some odd reason the images dont display straight away at load up, why is this? Can this also be resolved?

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 08-22-2006, 06:06 AM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
i can see that a lot of lines in your code do not end with a semi-colon. here are just a few. you may want to go through and clean that up, maybe it will help.

HTML Code:
var dir = "images/"
HTML Code:
window.status='Done'
var text = ''; // this one is ok
text +='<table border="0">'
__________________
Mike
sde is offline   Reply With Quote
Old 08-22-2006, 06:10 AM   #8 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
sde,

Where do i put them? Can you help?
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester 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
can not load php_ldap.dll sde PHP 2 03-28-2006 03:25 PM
Images won't load in my pages... elearley HTML, XML, Javascript, AJAX 3 05-25-2005 12:25 PM
Using PHP to retrieve images stored in MySQL metazai PHP 11 04-06-2005 01:05 AM
New images reaffirm planet is lord of rings redhead Code Newbie News 0 07-05-2004 12:56 AM
Installing and using CMUgraphics library. Valmont Standard C, C++ 12 03-29-2003 08:39 AM


All times are GMT -8. The time now is 11:59 AM.


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