473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Source of image from an array

Hi,
I have an array something like this.

var daylinks=new Array()
daylinks[1]="aarey_01"

var extn=new Array ()
extn=".html"
extn2=".jpg"

I want to display images in an HTML file without having to write the name of th image (in other words, by using the daylinks number) Can someone tell me who it can be done?
I have kept extension as a seprate array because the same array is used for the url (like aarey_01.html) as well as image source (aarey_01.jpg) For example see the code below where I can write url properly but have no clue about what to do for image source

<a href="#" onClick="window.location=daylinks[1]+extn;return false">What should come here to display the image</a>
Jul 20 '06 #1
1 1884
Arielle
76
I've used XSLT in the past for this sort of thing but in javascript but my question is how are you getting the content for the array?

I think it might be easier if you generated the links with the images through DOM by adding element nodes when you load rather than hardcoding it.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script language="javascript">
  3. var daylinks=new Array()
  4. daylinks[0]="aarey_01";
  5. daylinks[1]="aarey_02";
  6. function writePage()
  7. {
  8.   var myField = document.getElementById("myContainer");
  9.   for(var x=0;x<daylinks.length;x++)
  10.   {
  11.     var el = document.createElement('a');
  12.     el.href = "#";
  13.     el.onClick = "window.location=" + daylinks[x] + "+extn;return false";
  14.  
  15.     var elimg = document.createElement('img');
  16.     elimg.border = "0";
  17.     elimg.src = daylinks[x] + ".jpg";
  18.  
  19.     el.appendChild(elimg);
  20.     myField.appendChild(el);
  21.   }
  22. }
  23. </script>
  24. <body onLoad="writePage()">
  25. <div id="myContainer">
  26. </div>
  27. </body>
  28. </html>
  29.  
Jul 20 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id if the picture (an integer) and one (column named picture) is a field of type OLE Object which...
8
by: ctiggerf | last post by:
I was hopeing someone could help me out here. Been stumped on this one all day. This function 1. Checks uploaded files. 2. Creates two resized images from each (a full size, and a...
1
by: Sunshine192 | last post by:
Hi, I'm still kinda new to PHP so I could do with some advice. I'm using the code below to select and show a random image from a folder of images. rotate.php <?php // Make this the relative...
10
by: =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= | last post by:
Hi, Please help me to write a dll in C# , that will read each pages of a tiff image from a file and a memory stream object ( need two ways) and creatre a new tiff image object.The dll should...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
13
by: sachin | last post by:
Hi, Is it possible to do something like this: unsigned char arr = { #include "cFile.c" } I need that C source file cFile.c to compile and its binary output to include in array.
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
8
by: martinsmith160 | last post by:
Hi everyone I am trying to create a simple wpf program that allows a user to select an image from a combo box and then where they click on th screen draw that image at the mouse co-ordinates. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.