Howsit guys, I need to make a simple java script which will have a combo box full of options, and whatever the user clicks as an option that will define what image is displayed below.
my script is as follows:
<script language="javascript">
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
</script>
and my code is as follows:
<body>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="100%"><form name="mygallery"><p><select
name="picture" size="1" onChange="showimage()">
<option value="me.gif">me2</option>
</select></p>
</form>
</td>
</tr>
<tr>
<td width="100%" height="100%"><p align="center"><img src="me.gif" name="pictures" width="99" height="100"></p></td>
</tr>
</table>
</body>
now the problem is it displays "me.gif" fine but when i add more options and map them to another image, it doesnt display that image. infact when i delete me.gif from the source folder it still displays me.gif?? what am i doing wrong?
thanks in advanced!
simple java script help
simple java script help
when in doubt, paddle out...
Re: simple java script help
im a n00b, lol i was working out of a folder while the source i was editing was in a different folder...*sigh* see what the december rush does to a person?!
when in doubt, paddle out...
-
- Registered User
- Posts: 14085
- Joined: 06 Oct 2004, 02:00
- Location: Location, Location...
- Contact:
Re: simple java script help
Dunno what you're doing wrong, but it work fine when I used your code as is. I added one extra pic:
Check the second option. Was just a copy/paste job from the option statement you provided. Tested in FF3.
Edit: And since you're not specifying relative or absolute paths, your pics are located in the same directory as your html file, right?
Code: Select all
<html>
<head>
<script language="javascript">
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
</script>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="100%"><form name="mygallery"><p><select
name="picture" size="1" onChange="showimage()">
<option value="me.gif">me2</option>
<option value="test.gif">Stallone</option>
</select></p>
</form>
</td>
</tr>
<tr>
<td width="100%" height="100%"><p align="center"><img src="me.gif" name="pictures" width="99" height="100"></p></td>
</tr>
</table>
</body>
</html>
Edit: And since you're not specifying relative or absolute paths, your pics are located in the same directory as your html file, right?
Last edited by SykomantiS on 03 Dec 2008, 16:05, edited 4 times in total.
Re: simple java script help
yeah found my fault, it was a long day, multiple clients work open at the same time and being a n00b lol thanks tho hehe
when in doubt, paddle out...