gib65
05-23-2010, 08:23 PM
Hello,
I'm trying to do something with my art website that's turning out to be tricky. There's an easy way to explain this and there's a complicated way. Let's start with the easy way.
I'm trying to create a hyperlink around an image that turns on or off depending on what image is displayed. The image itself is dynamic; it sits in the middle of the page and changes depending on which thumb the user clicks (which themselves sit on the left of the page). There's one image in particular that I want to make into a hyperlink (but the rest are just images). The only tool I know of that comes close to implementing this is the display attribute that belongs to the hyperlink tag. When the user clicks on the thumb of the particular image to be made into a hyperlink, I would set (using javascript) the display attribute to 'inline' and when the user clicks on any other thumb I would set the display attribute to 'none'.
This doesn't quite work for my purposes, however, because setting the hyperlink display attribute to 'none' makes the whole image dissappear, not just its being a hyperlink. This is what I need help with. I need to work with something other than the display attribute (or some other approach all together), something that makes the image into a hyperlink and then back again without making the image itself dissappear. I'm at a loss though. Any help would be much appreciated.
Now for the complicated version. It's only complicated because of the sheer amount of code involved; so if you can understand the above, you can skip this part. If you need to see the code, read on at your own peril :). (btw, the URL is http://www.shahspace.com/art2).
The code begins in index.html. The relevant sections are in bold:
<script type="text/javascript" src="motiongallery2.js">
/***********************************************
* CMotion Image Gallery II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* Modified by jscheuer1 for vertical orientation, at http://www.dynamicDrive.com/forums
***********************************************/
/* source: http://www.dynamicdrive.com/dynamicindex4/cmotiongallery.htm */
</script>
<script language="javascript" type="text/javascript" src="functions.js"></script>
<!-- #include file="variables.inc" -->
</head>
<body style="background-color: black;">
<!-- #include file="fracturesmap.inc" -->
...
<!-- Gallery Content below -->
...
<tr><td><a href="#nogo" onclick="changePic(BULLS_EYE);return false;"><img src="thumbs/bulls_eye.jpg" border=1></a><br>Bull's Eye</td></tr>
<tr><td><a href="#nogo" onclick="changePic(FRACTURES);return false;"><img src="thumbs/fractures.jpg" border=1></a><br>Fractures</td></tr>
<tr><td><a href="#nogo" onclick="changePic(RUNNING_FROM_THE_LIGHT);return false;"><img src="thumbs/running_from_the_light.jpg" border=1></a><br>Running From the Light</td></tr>
...
<center>
<a id="fractureslink" href="#nogo" onmouseover="mainpic.src='mainpics/fractures_odd.jpg'" onmouseout="mainpic.src='mainpics/fractures_even.jpg'" usemap="#fracturesmap" border=0>-->
<img id="mainpic" style="border: 3px double darkred;" alt="mainpic" border=1>
</a>
</center>
Here's the relevant javascript function from function.js:
function changePic(num) {
mainpic.src="mainpics/"+files[num];
title.innerHTML = titles[num];
date.innerHTML = dates[num];
comment_body.innerHTML = comments[num];
cur_pic=num;
if (cur_pic == last_pic) {
nextlink.style.display = "none";
}
else {
nextlink.style.display = "inline";
}
if (cur_pic == first_pic) {
prevlink.style.display = "none";
}
else {
prevlink.style.display = "inline";
}
if (cur_pic == FRACTURES) {
fractureslink.style.display = "inline";
}
else {
fractureslink.style.display = "none";
}
}
The hyperlink is complicated more by a area map but I doubt this is relevant to the question I'm asking, but if you want to see it, I'd be happy to post it.
Anyway, I hope someone can help me with this problem. Thanks in advance.
I'm trying to do something with my art website that's turning out to be tricky. There's an easy way to explain this and there's a complicated way. Let's start with the easy way.
I'm trying to create a hyperlink around an image that turns on or off depending on what image is displayed. The image itself is dynamic; it sits in the middle of the page and changes depending on which thumb the user clicks (which themselves sit on the left of the page). There's one image in particular that I want to make into a hyperlink (but the rest are just images). The only tool I know of that comes close to implementing this is the display attribute that belongs to the hyperlink tag. When the user clicks on the thumb of the particular image to be made into a hyperlink, I would set (using javascript) the display attribute to 'inline' and when the user clicks on any other thumb I would set the display attribute to 'none'.
This doesn't quite work for my purposes, however, because setting the hyperlink display attribute to 'none' makes the whole image dissappear, not just its being a hyperlink. This is what I need help with. I need to work with something other than the display attribute (or some other approach all together), something that makes the image into a hyperlink and then back again without making the image itself dissappear. I'm at a loss though. Any help would be much appreciated.
Now for the complicated version. It's only complicated because of the sheer amount of code involved; so if you can understand the above, you can skip this part. If you need to see the code, read on at your own peril :). (btw, the URL is http://www.shahspace.com/art2).
The code begins in index.html. The relevant sections are in bold:
<script type="text/javascript" src="motiongallery2.js">
/***********************************************
* CMotion Image Gallery II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* Modified by jscheuer1 for vertical orientation, at http://www.dynamicDrive.com/forums
***********************************************/
/* source: http://www.dynamicdrive.com/dynamicindex4/cmotiongallery.htm */
</script>
<script language="javascript" type="text/javascript" src="functions.js"></script>
<!-- #include file="variables.inc" -->
</head>
<body style="background-color: black;">
<!-- #include file="fracturesmap.inc" -->
...
<!-- Gallery Content below -->
...
<tr><td><a href="#nogo" onclick="changePic(BULLS_EYE);return false;"><img src="thumbs/bulls_eye.jpg" border=1></a><br>Bull's Eye</td></tr>
<tr><td><a href="#nogo" onclick="changePic(FRACTURES);return false;"><img src="thumbs/fractures.jpg" border=1></a><br>Fractures</td></tr>
<tr><td><a href="#nogo" onclick="changePic(RUNNING_FROM_THE_LIGHT);return false;"><img src="thumbs/running_from_the_light.jpg" border=1></a><br>Running From the Light</td></tr>
...
<center>
<a id="fractureslink" href="#nogo" onmouseover="mainpic.src='mainpics/fractures_odd.jpg'" onmouseout="mainpic.src='mainpics/fractures_even.jpg'" usemap="#fracturesmap" border=0>-->
<img id="mainpic" style="border: 3px double darkred;" alt="mainpic" border=1>
</a>
</center>
Here's the relevant javascript function from function.js:
function changePic(num) {
mainpic.src="mainpics/"+files[num];
title.innerHTML = titles[num];
date.innerHTML = dates[num];
comment_body.innerHTML = comments[num];
cur_pic=num;
if (cur_pic == last_pic) {
nextlink.style.display = "none";
}
else {
nextlink.style.display = "inline";
}
if (cur_pic == first_pic) {
prevlink.style.display = "none";
}
else {
prevlink.style.display = "inline";
}
if (cur_pic == FRACTURES) {
fractureslink.style.display = "inline";
}
else {
fractureslink.style.display = "none";
}
}
The hyperlink is complicated more by a area map but I doubt this is relevant to the question I'm asking, but if you want to see it, I'd be happy to post it.
Anyway, I hope someone can help me with this problem. Thanks in advance.