PDA

View Full Version : image selector shown in different frame


Smou
04-20-2003, 08:23 AM
hi, i am using http://javascriptkit.com/script/cut173.shtml and i am wondering if it's possible to make the image be shown in an other frame.

so that there is the frame called "select" where i select the image to be shown and that there is a frame called "show" where the image is been show


is this possible?

greets

shlagish
04-21-2003, 05:54 AM
I don't know if this is what you're looking for but:

main.html

<frameset rows="20%,*">

<frame src="frame1.html" name="frame1">

<frame src="frame2.html" name="frame2">

</frameset>

The following is frame1.html:

<html>
<head>
<script language="javascript">
<!--

function showimage()
{
if (!document.images)
return
parent.frame2.document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
//-->
</script>
</head>
<body>
<form name="mygallery">
<p>
<select name="picture" size="1" onChange="showimage()">
<option selected value="me.gif">Picture of me</option>
<option value="myaunt.gif">Picture of my aunt</option>
<option value="brother.gif">Picture of my brother</option>
</select>
</p>
</form>
</td>
</tr>
</table>
</body>
</html>

The following is frame2.html

<html>
<body>
<p align="center">
<img src="me.gif" name="pictures" width="99"
height="100">
</p>
</body>
</html>

I did not test this but I think it should work

Smou
04-21-2003, 06:20 AM
well thanks but it does not work.

i am not sure but may it be that it is not working because i am using it inside an iframe?

i mean i got the selector inside an iframe (named "iframe") and i want the image to be displayed on the site the iframe is based in, that frame is named "full"

(of course i renamed the framename within your code)

glenngv
04-21-2003, 06:33 AM
top.frames['full'].document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value

Smou
04-21-2003, 07:03 AM
great job! it works! :)))

thanks a lot!

Smou
04-21-2003, 11:08 AM
i got one more question: is it possible to use the image selector with a normal link? i mean that i just click onto a thumbnail or text link and that the real image is shown.

shlagish
04-22-2003, 02:51 AM
Yes it is possible:

try this as an example:

<html>
<head>
<script type="text/javascript">
<!--
function change_image(new_image)
{
document.all.my_image.src=new_image;
}
-->
</script>
</head>
<body>
<a href="#" onClick="change_image('myaunt.gif')">link</a>
<br />
<a href="#" onClick="change_image('brother.gif')">link2</a>
<br />
<br />
<img id="my_image" src="me.gif" />
</body>
</html>

again, I didn't test, it might not work...
This might not work across browsers, but that's only a few modifications...

glenngv
04-22-2003, 06:18 AM
...
document.images['my_image'].src=new_image;
...
<img name="my_image" src="me.gif" />

Smou
04-22-2003, 09:15 AM
thx but i want to use it together with the selector. so that i can do links AND the selector. and that it's all shown in one single image.

glenngv
04-23-2003, 10:13 AM
function showimage2(imgPath)
{
if (!document.images) return;
top.frames['full'].document.images.pictures.src=imgPath;
return false; //cancels href
}
...
<a href="#" onClick="return showimage2('myaunt.gif')">link</a>
<a href="#" onClick="return showimage2('brother.gif')">link2</a>