PDA

View Full Version : Slideshow shows 'Undefined' text



Rockpapercopy
03-04-2016, 03:39 PM
Hi Guys,

I was wondering if you could help. I've been playing with slideshows today and found great one at Dynamic Drive. Yet after integrating the code, the text underneath shows: 'Undefined' and I have no idea where to change it / remove it. Please help? Below is the code and screen shot:

5841



<script language="JavaScript1.2">

var variableslide=new Array()

//variableslide[x]=["path to image", "OPTIONAL link for image", "OPTIONAL text description (supports HTML tags)"]

variableslide[0]=["https://farm2.staticflickr.com/1497/25124601229_90604fb064_b.jpg"]
variableslide[1]=["https://farm2.staticflickr.com/1544/25196538220_755bfa57b8_b.jpg"]
variableslide[2]=["https://farm2.staticflickr.com/1711/24865434833_8759084fed_k.jpg"]
variableslide[3]=["https://farm2.staticflickr.com/1709/25373709692_bbbd7d1da8_k.jpg"]
variableslide[4]=["https://farm2.staticflickr.com/1603/25466014396_475df73d82_b.jpg"]
variableslide[5]=["https://farm2.staticflickr.com/1556/25373732262_7ce94cecb5_b.jpg"]
variableslide[6]=["https://farm2.staticflickr.com/1537/25492103585_d2339eee89_b.jpg"]
variableslide[7]=["https://farm2.staticflickr.com/1529/24861576224_d10ddae157_b.jpg"]
variableslide[8]=["https://farm2.staticflickr.com/1466/25124597469_d8dec7aeac_b.jpg"]

//configure the below 3 variables to set the dimension/background color of the slideshow

var slidewidth='1024px' //set to width of LARGEST image in your slideshow
var slideheight='683px' //set to height of LARGEST iamge in your slideshow, plus any text description
var slidebgcolor='#ffffff'

//configure the below variable to determine the delay between image rotations (in miliseconds)
var slidedelay=3000

////Do not edit pass this line////////////////

var ie=document.all
var dom=document.getElementById

for (i=0;i<variableslide.length;i++){
var cacheimage=new Image()
cacheimage.src=variableslide[i][0]
}

var currentslide=0

function rotateimages(){
contentcontainer='<center>'
if (variableslide[currentslide][1]!="")
contentcontainer+='<a href="'+variableslide[currentslide][1]+'">'
contentcontainer+='<img src="'+variableslide[currentslide][0]+'" border="0" vspace="3">'
if (variableslide[currentslide][1]!="")
contentcontainer+='</a>'
contentcontainer+='</center>'
if (variableslide[currentslide][2]!="")
contentcontainer+=variableslide[currentslide][2]

if (document.layers){
crossrotateobj.document.write(contentcontainer)
crossrotateobj.document.close()
}
else if (ie||dom)
crossrotateobj.innerHTML=contentcontainer
if (currentslide==variableslide.length-1) currentslide=0
else currentslide++
setTimeout("rotateimages()",slidedelay)
}

if (ie||dom)
document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')

function start_slider(){
crossrotateobj=dom? document.getElementById("slidedom") : ie? document.all.slidedom : document.slidensmain.document.slidenssub
if (document.layers)
document.slidensmain.visibility="show"
rotateimages()
}

if (ie||dom)
start_slider()
else if (document.layers)
window.onload=start_slider

</script>

<ilayer id="slidensmain" width=&{slidewidth}; height=&{slideheight}; bgColor=&{slidebgcolor}; visibility=hide><layer id="slidenssub" width=&{slidewidth}; left=0 top=0></layer></ilayer>

<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided by<br>
<a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>

jscheuer1
03-04-2016, 06:26 PM
This little part here is an instruction/template:


//variableslide[x]=["path to image", "OPTIONAL link for image", "OPTIONAL text description (supports HTML tags)"]

However, here:


variableslide[0]=["https://farm2.staticflickr.com/1497/25124601229_90604fb064_b.jpg"]
variableslide[1]=["https://farm2.staticflickr.com/1544/25196538220_755bfa57b8_b.jpg"]
variableslide[2]=["https://farm2.staticflickr.com/1711/24865434833_8759084fed_k.jpg"]
variableslide[3]=["https://farm2.staticflickr.com/1709/25373709692_bbbd7d1da8_k.jpg"]
variableslide[4]=["https://farm2.staticflickr.com/1603/25466014396_475df73d82_b.jpg"]
variableslide[5]=["https://farm2.staticflickr.com/1556/25373732262_7ce94cecb5_b.jpg"]
variableslide[6]=["https://farm2.staticflickr.com/1537/25492103585_d2339eee89_b.jpg"]
variableslide[7]=["https://farm2.staticflickr.com/1529/24861576224_d10ddae157_b.jpg"]
variableslide[8]=["https://farm2.staticflickr.com/1466/25124597469_d8dec7aeac_b.jpg"]

For each on you have left , "OPTIONAL link for image", "OPTIONAL text description (supports HTML tags)" both "undefined" only the description is shown though, so that's what you see. Now, while coding this script that could have been dealt with. But it wasn't. So you have to by supplying empty fields for any of the options you don't want to use, like so:


variableslide[0]=["https://farm2.staticflickr.com/1497/25124601229_90604fb064_b.jpg", "", ""]
variableslide[1]=["https://farm2.staticflickr.com/1544/25196538220_755bfa57b8_b.jpg", "", ""]
variableslide[2]=["https://farm2.staticflickr.com/1711/24865434833_8759084fed_k.jpg", "", ""]
variableslide[3]=["https://farm2.staticflickr.com/1709/25373709692_bbbd7d1da8_k.jpg", "", ""]
variableslide[4]=["https://farm2.staticflickr.com/1603/25466014396_475df73d82_b.jpg", "", ""]
variableslide[5]=["https://farm2.staticflickr.com/1556/25373732262_7ce94cecb5_b.jpg", "", ""]
variableslide[6]=["https://farm2.staticflickr.com/1537/25492103585_d2339eee89_b.jpg", "", ""]
variableslide[7]=["https://farm2.staticflickr.com/1529/24861576224_d10ddae157_b.jpg", "", ""]
variableslide[8]=["https://farm2.staticflickr.com/1466/25124597469_d8dec7aeac_b.jpg", "", ""]

That will take care of it!