Solved

loading images

Posted on 2003-10-27
6
154 Views
Last Modified: 2010-04-09
currently if have a pretty long routine to load customer logo's.
i am loading them into a table format loading individual images by name.
it becomes a problem when i have to load new ones, because i have to rewrite the page to keep the order correct.

is there a way to read a directory that the images are in and load them in alpha order?

current code.
 <td class="td_maintext">
            <table border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td><img src="images/a1.jpg" width="99" height="96"></td>
                <td><img src="images/a2.jpg" width="99" height="96"></td>
                <td><img src="images/a3.jpg" width="99" height="96"></td>
                <td><img src="images/a4.jpg" width="99" height="96"></td>
              </tr>
              <tr>
                <td><img src="images/a5.jpg" width="99" height="96"></td>
                <td><img src="images/a6.gif" width="99" height="96"></td>
                <td><img src="images/a7.jpg" width="99" height="96"></td>
                <td><img src="images/a8.jpg" width="99" height="96"></td>
              </tr>
              <tr>
           
and so on
thanks for any help
0
Comment
Question by:jafrazee
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Xxavier
ID: 9630931
Try this

<td class="td_maintext">
            <table border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td><img  width="99" height="96"></td>
                <td><img  width="99" height="96"></td>
                <td><img  width="99" height="96"></td>
                <td><img  width="99" height="96"></td>
              </tr>
              <tr>
                <td><img  width="99" height="96"></td>
                <td><img  width="99" height="96"></td>
                <td><img  width="99" height="96"></td>
                <td><img  width="99" height="96"></td>
              </tr>
              <tr>



             <table>

<script>
ImArray= new Array("images/a1.jpg","images/a2.jpg","images/a3.jpg",  ..etc )
for (i=0;i<=document.images.length-1;i++)
   {document.images[i].src=ImArray[i]}
</script>
0
 
LVL 2

Author Comment

by:jafrazee
ID: 9631199
the array loads onto the web document but does not load into my table.
am i missing a step?
0
 
LVL 7

Expert Comment

by:Xxavier
ID: 9642282
Show me your code.
0
 

Accepted Solution

by:
BakaMattSu earned 50 total points
ID: 9827918
Xxavier's suggestion will work, but only assuming the code you've given is all that's on your page. Just modify it as follows to specifically target the images in your table, and it should load properly again:

<table border="0" cellspacing="10" cellpadding="0">
              <tr>
                <td><img id="logo0"  width="99" height="96"></td>
                <td><img id="logo1"  width="99" height="96"></td>
                <td><img id="logo2"  width="99" height="96"></td>
                <td><img id="logo3" width="99" height="96"></td>
              </tr>
              <tr>
                <td><img id="logo4"  width="99" height="96"></td>
                <td><img id="logo5"  width="99" height="96"></td>
                <td><img id="logo6"  width="99" height="96"></td>
                <td><img id="logo7"  width="99" height="96"></td>
              </tr>
              <tr>
<table>

<script>
ImArray= new Array("images/a1.jpg","images/a2.jpg","images/a3.jpg",  ..etc )
for (i=0;i<ImArray.length;i++) {
     document.images["logo"+i].src=ImArray[i];
}
</script>
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pass form variable from one web form to another 2 29
Opening a new tab in IE using Powershell / HTML 2 21
Responsive Font Size 6 29
..ignore the Question 1 8
This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question