...

View Full Version : Problems re using a line of HTML



Vito B
11-07-2006, 02:58 PM
I wish to change a prototype web page which currently uses 15 lines of HTML to display 15 photos into one which displays 15 photos by reusing a single line of HTML.
The relevant part of my initial attempt is shown below.
The first part of the while loop successfully puts the filename into the HTML line.
But I cannot get the string held in shortdes to be used in place of Photo title or the string held in style to be used in place of s1.

Any assistance would be gratefully received.
Many thanks

<body>
<img name="gallery" src="blank.jpg" alt="Photo title" div class="s1">

<script>
count=1
while (count<6)
{
function change(jpgName,desc,styleName)
{
var filename=jpgName.toString()+".jpg"
document.gallery.src=filename

var shortdes=desc.toString()
document.gallery.alt=shortdes

var style=styleName.toString()
document.gallery.div=style
}

_Aerospace_Eng_
11-07-2006, 03:48 PM
Where are jpgName, desc, and styleName coming from?

Vito B
11-07-2006, 06:28 PM
Thanks for your response.
jpgName, desc, and styleName are being read from arrays set up in the head.
I have used Alert to check that filename, shortdes and style contain the required strings. I just don't understand why filename is substituted correctly and shortdes and style are not.

_Aerospace_Eng_
11-08-2006, 12:20 AM
Try this

var count = 1
while (count < 6)
{
function change(jpgName,desc,styleName)
{
var el = document.images['gallery'];
var filename = jpgName.toString()+".jpg"
el.setAttribute('src',filename);

var shortdes = desc.toString()
el.setAttribute('alt',shortdes);

var style1 = styleName.toString()
el.className = style1;
}
}

Vito B
11-08-2006, 12:59 PM
This is perfect.
Very many thanks for your speedy solution to this problem.
Vito B



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum