SilverJack
Programmer
Hi everybody,
I'm using a slideshow script. It works well, but now I need that every image (when clicked) shows a text on another div. Here's the code:
<!-- I just created three arrays -->
var slide1 = new Array("slideshow/img1.jpg","slideshow/img2.jpg","slideshow/img3.jpg");
var slide2 = new Array("slideshow/img4.jpg","slideshow/img5.jpg","slideshow/img6.jpg");
var slide3 = new Array("slideshow/img7.jpg","slideshow/img8.jpg","slideshow/img9.jpg");
<!-- this is the slideshow script -->
var i = 0;
var j = 0;
var k = 0;
function Backward()
{
if (i == 0 && j == 0 && k == 0)
{
i = slide1.length - 1;
j = slide2.length - 1;
k = slide3.length - 1;
}
else
{
i--;
j--;
k--;
}
document.sld1.src = slide1;
document.sld2.src = slide2[j];
document.sld3.src = slide3[k];
}
function Forward()
{
if (i < slide1.length - 1 && j < slide2.length - 1 && k < slide3.length - 1)
{
i++;
j++;
k++;
}
else
{
i=0;
j=0;
k=0;
}
document.sld1.src = slide1;
document.sld2.src = slide2[j];
document.sld3.src = slide3[k];
}
Now, I created three new arrays with some texts:
var TxtArr1 = new Array ('First Text','Second Text','Third Text');
var TxtArr2 = new Array ('Fourth Text','Fifth Text', 'Sixth Text');
var TxtArr3 = new Array ('Seventh Text','Eight text','Ninth Text');
And then I tried with this function:
function ImgToTxt(id)
{
var obj = document.getElementById(id);
for (i=0; i <= slide1.length; i++)
{
for (j=0; j <= TxtArr1.length; j++)
{
if (slide1 == TxtArr1[j])
{
var divtext = obj.createTextNode(""+TxtArr1[j]);
obj.appendChild(divtext);
}
}
}
}
But it's wrong. Any idea of how could I change it to make it work? Any help would be appreciated.
Thank You.
SilverJack
I'm using a slideshow script. It works well, but now I need that every image (when clicked) shows a text on another div. Here's the code:
<!-- I just created three arrays -->
var slide1 = new Array("slideshow/img1.jpg","slideshow/img2.jpg","slideshow/img3.jpg");
var slide2 = new Array("slideshow/img4.jpg","slideshow/img5.jpg","slideshow/img6.jpg");
var slide3 = new Array("slideshow/img7.jpg","slideshow/img8.jpg","slideshow/img9.jpg");
<!-- this is the slideshow script -->
var i = 0;
var j = 0;
var k = 0;
function Backward()
{
if (i == 0 && j == 0 && k == 0)
{
i = slide1.length - 1;
j = slide2.length - 1;
k = slide3.length - 1;
}
else
{
i--;
j--;
k--;
}
document.sld1.src = slide1;
document.sld2.src = slide2[j];
document.sld3.src = slide3[k];
}
function Forward()
{
if (i < slide1.length - 1 && j < slide2.length - 1 && k < slide3.length - 1)
{
i++;
j++;
k++;
}
else
{
i=0;
j=0;
k=0;
}
document.sld1.src = slide1;
document.sld2.src = slide2[j];
document.sld3.src = slide3[k];
}
Now, I created three new arrays with some texts:
var TxtArr1 = new Array ('First Text','Second Text','Third Text');
var TxtArr2 = new Array ('Fourth Text','Fifth Text', 'Sixth Text');
var TxtArr3 = new Array ('Seventh Text','Eight text','Ninth Text');
And then I tried with this function:
function ImgToTxt(id)
{
var obj = document.getElementById(id);
for (i=0; i <= slide1.length; i++)
{
for (j=0; j <= TxtArr1.length; j++)
{
if (slide1 == TxtArr1[j])
{
var divtext = obj.createTextNode(""+TxtArr1[j]);
obj.appendChild(divtext);
}
}
}
}
But it's wrong. Any idea of how could I change it to make it work? Any help would be appreciated.
Thank You.
SilverJack