right idea.....but lost somewhere

R

Richard

This simple change to dynamicdrive's textual tooltip does what I want
perfectly.
(whichcontent) determines which group of thumbs will be shown.
My color coded editor is showing me that something is not quite kosher and I
can't figure out what it is.
Everything appears to be fine up until you get to i<10 then it screws up.

I know everything else works fine.
With a click, I can put a single image into my "middle" column with ease.
But I want to show the entire group of thumbs, not just one.

Any clues appreciated.



function changethumbs(whichcontent){

if (document.all||document.getElementById){
cross_el=document.getElementById?
document.getElementById("middle"):document.all.middle
counter=0
for (i=1; i<10; i++){
counter=counter+1
cross_el.innerHTML='<img src="images/pic"+i+".jpg">'

}


}

}
 
R

RobG

Richard said:
This simple change to dynamicdrive's textual tooltip does what I want
perfectly.
(whichcontent) determines which group of thumbs will be shown.
My color coded editor is showing me that something is not quite kosher and I
can't figure out what it is.
Everything appears to be fine up until you get to i<10 then it screws up.

i<10 means that it will stop when i reaches 9.
I know everything else works fine.
With a click, I can put a single image into my "middle" column with ease.
But I want to show the entire group of thumbs, not just one.

function changethumbs(whichcontent){

if (document.all||document.getElementById){
cross_el=document.getElementById?
document.getElementById("middle"):document.all.middle

this can be written a little more legibly as:

if (document.getElementById){
var cross_el = document.getElementById('middle');
} else if (document.all) {
var cross_el = document.all['middle'];
}
counter=0

Don't know what "counter" is for, but make it local if not needed as
global:

var counter = 0;
for (i=1; i<10; i++){

This for loop will iterate 9 times, from 1 to 9 inclusive. If you want
more, say 20, change i<10 to i<=20.
counter=counter+1
cross_el.innerHTML='<img src="images/pic"+i+".jpg">'

"cross_el" must be a div or span or similar, so this can be
replaced by:

if (document.createElement) {
counter++;
var image = document.createElement('img');
image.src = 'images/pic' + i + '.jpg';
image.alt = 'nothing';
cross_el.appendChild(image);
}

[...]
 
R

Richard

I must be missing something because I can't get your idea to work right.
Thanks for the lesson.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top