[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

loading images

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
jafrazee
Asked:
jafrazee
  • 2
1 Solution
 
XxavierCommented:
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
 
jafrazeeAuthor Commented:
the array loads onto the web document but does not load into my table.
am i missing a step?
0
 
XxavierCommented:
Show me your code.
0
 
BakaMattSuCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now