[thelist] Another Javascript question

Daniel McMurray mcmurd at ccaa.edu
Wed Aug 9 21:27:29 CDT 2000


Hello!  I've got another javascript question for any that would care to
help out.

I'm trying to create a photo album.  My goal is to have an image inside a
table cell, with a row of numbers under it.  A mouseover (or click, it
doesn't matter, really) on one of the numbers will change the image inside
the table cell.  I've got this down, no problem.
The part that's making me pull my hair out is that I also would like a
button below the row of numbers that, when clicked, will open a new window
with a large version of whatever image is currently being viewed.  I've
been using an if statement to cover this (if the image source is
equal to a certain picture, then open the large version)
The problem I'm currently facing is that when I have more than 1 if
statement, a click on the button opens all images that are used in any of
the if statements!  I've used several different methods - writing out long
if statements, passing an assigned variable through a hidden form field,
assigning the pertinent images to array values and repeating steps
1-10....you get the idea.  Nothing seems to work!  It all ends up opening
all of the images in separate windows at the same time.

For some reason, I've got this feeling that the answer is either really
easy or impossible to achieve.

Here's the latest incarnation of the code I'm using (without the comment
tags, of course).  It's not elegant by any measure, but I'd at least like
it to do its job!  :-)

<!--

<html>
<head>
<script language="javascript">
var stuff = new Array("somepic-sm.jpg", "someotherpic-sm.jpg");
var thing = new Array("somepic-lg.jpg", "someotherpic-lg.jpg");

function change(name, source) {
	document[name].src = source;
	}
function viewlarge() {
	x = document.flip.src;
	if (x = stuff[0]) { window.open(thing[0]) };
	if (x = stuff[1]) { window.open(thing[1]) };
	}
</script>
</head>
<body>

<img src="blank.gif" height="135" width="135" name="flip">
<br>
<a href="stuff" onMouseOver="change('flip', stuff[0])">stuff</a>
&nbsp;&nbsp;&nbsp;
<a href="stuff" onMouseOver="change('flip', stuff[1])">stuff</a>

<br>
<input type="button" value="view" onClick="viewlarge();">

</body>
</html>

-->

Thanks a lot, and sorry for the long message!
Dan






More information about the thelist mailing list