View Full Version : Problems re using a line of HTML

Vito B
Nov 7th, 2006, 03: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

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

while (count<6)
function change(jpgName,desc,styleName)
var filename=jpgName.toString()+".jpg"

var shortdes=desc.toString()

var style=styleName.toString()

Nov 7th, 2006, 04:48 PM
Where are jpgName, desc, and styleName coming from?

Vito B
Nov 7th, 2006, 07: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.

Nov 8th, 2006, 01: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"

var shortdes = desc.toString()

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

Vito B
Nov 8th, 2006, 01:59 PM
This is perfect.
Very many thanks for your speedy solution to this problem.
Vito B