res11295
09-07-2005, 03:30 AM
I am currently modifying a DD script, Image Thumbnail Viewer II. But my question is a generic Javascript question.
How do I pass a value of an array to a funtion and then read it?
Exmaple:
var dynimages=new Array()
dynimages[0]=["wed01_medium.jpg", "wed01_large..jpg"]
I want to be able to store the image width and height. I'm not sure but think it should be like this:
dynimages[0]=["wed01_medium.jpg", "wed01_large.jpg",600,800]
Now I want to pass the values to the funtion below and replace the width and height values with the one in my array. I can't figure that out. Can someone help?
function returnimgcode(theimg){
var imghtml=""
if (theimg[1]!="")
imghtml='<a href="'+theimg[1]+'" onclick="window.open(this.href,\'popupwindow\',\'width=500,height=500,scrollbars=no,statusbar=no,resizable=yes,\');return false;" target="_blank">'
imghtml+='<img src="'+theimg[0]+'" border="'+imgborderwidth+'">'
if (theimg[1]!="")
imghtml+='</a>'
return imghtml
}
function modifyimage(loadarea, imgindex){
if (document.getElementById){
var imgobj=document.getElementById(loadarea)
if (imgobj.filters && window.createPopup){
imgobj.style.filter=filterstring
imgobj.filters[0].Apply()
}
imgobj.innerHTML=returnimgcode(dynimages[imgindex])
if (imgobj.filters && window.createPopup)
imgobj.filters[0].Play()
return false
}
}
THANK YOU!
How do I pass a value of an array to a funtion and then read it?
Exmaple:
var dynimages=new Array()
dynimages[0]=["wed01_medium.jpg", "wed01_large..jpg"]
I want to be able to store the image width and height. I'm not sure but think it should be like this:
dynimages[0]=["wed01_medium.jpg", "wed01_large.jpg",600,800]
Now I want to pass the values to the funtion below and replace the width and height values with the one in my array. I can't figure that out. Can someone help?
function returnimgcode(theimg){
var imghtml=""
if (theimg[1]!="")
imghtml='<a href="'+theimg[1]+'" onclick="window.open(this.href,\'popupwindow\',\'width=500,height=500,scrollbars=no,statusbar=no,resizable=yes,\');return false;" target="_blank">'
imghtml+='<img src="'+theimg[0]+'" border="'+imgborderwidth+'">'
if (theimg[1]!="")
imghtml+='</a>'
return imghtml
}
function modifyimage(loadarea, imgindex){
if (document.getElementById){
var imgobj=document.getElementById(loadarea)
if (imgobj.filters && window.createPopup){
imgobj.style.filter=filterstring
imgobj.filters[0].Apply()
}
imgobj.innerHTML=returnimgcode(dynimages[imgindex])
if (imgobj.filters && window.createPopup)
imgobj.filters[0].Play()
return false
}
}
THANK YOU!