PDA

View Full Version : calling image name


nemex
12-12-2002, 03:34 AM
The script below displays a defined number of images (display picture function) and when clicked on, the full picture opens in a popup (view full picture function). My images are 1.jpg, 2.jpg, ... 4.jpg. Problem is that the full picture does not display in the popup. I think that the cause of this is because the value of "x" is not defined for the openNaked() function...??

Is there a way to fix this, perhaps by passing a value...?

Thanks!!

<script language="javascript">
//display picture function
var numofimages = 5
for (x=1; x<numofimages; x++){
document.write("<a href=# onclick=openNaked()><img src=images/"+x+".jpg height=100 width=50 border=0></a>")}

//view full picture function
var Naked=null
function openNaked() {
Naked=window.open("", "Naked", "fullscreen,scrollbars")
Naked.document.write("<html><head></head><body><img src=images/"+x+".jpg border=0></body></html>")
Naked.window.resizeTo(400,100)
}
</SCRIPT>

Roelf
12-12-2002, 06:44 AM
<script language="javascript">
//display picture function
var numofimages = 5
for (x=1; x<numofimages; x++){
document.write("<a href=# onclick=openNaked(" + x + ")><img src=images/"+x+".jpg height=100 width=50 border=0></a>")}

//view full picture function
var Naked=null
function openNaked(x) {
Naked=window.open("", "Naked", "fullscreen,scrollbars")
Naked.document.write("<html><head></head><body><img src=images/"+x+".jpg border=0></body></html>")
Naked.window.resizeTo(400,100)
}

nemex
12-13-2002, 03:35 PM
thanks. it works now. but i want to add another variable so i dont have to make a separate dir for each group of images i have (as well as a separate "view full picture function").

Hehe, I tried imitating the way you passed the variable "x", but it doesnt work. Please correct, thanks. :)

//display picture function
var numofimages = 5
var grp = "happy"
for (x=1; x<numofimages; x++){
document.write("<a href=# onclick=openNaked("+grp+x+")><img src=images/"+grp+x+".jpg height=100 width=50 border=0></a>")}

//view full picture function
var Naked=null
function openNaked(grp,x) {
Naked=window.open("", "Naked", "fullscreen,scrollbars")
Naked.document.write("<html><head></head><body><img src=images/"+grp+x+".jpg border=0></body></html>")
Naked.window.resizeTo(400,100)
}

nemex
12-13-2002, 06:05 PM
Never mind this question. I've finally figured it out myself. Thanks for the help.