PDA

View Full Version : Using the same Java script twice on a page



avidcat
02-10-2006, 05:06 PM
I would like to use the same Javascript twice on the same page. Is there a work around to do this?

Basically I am going to add this script in a form and I need them to have the option of selecting two images.

here is the script:


<script language="javascript">
function changePicture()
{
var selection = document.DropPicture.Picture.selectedIndex; //grabs what user selected
document.pic.src = document.DropPicture.Picture.options[selection].value; //adds 'selection' to grab 'value'
}
</script>
<form name="DropPicture">
<select name="Picture" onChange="changePicture()">
<!---Calls The Function--->
<option selected>Pictures!
<option value="1.gif">Picture One
<option value="2.gif">Picture Two
</select>
</form></td>
<td width="84%"><img src="blank.gif" name="pic" border="0">

thanks,
Nick

Twey
02-10-2006, 05:25 PM
Pfft.

avidcat
02-10-2006, 05:40 PM
Ok well thanks anyway. I did see that help page here on Dynamic Forums but the script I am using doesn't have those tags.

I will keep looking for a fix. I am just a javascript user not a writer so things like this are a bit above me. :)

Nick

Twey
02-10-2006, 07:08 PM
I posted that sticky not to say "go away," but to point out the links contained within it :) It does apply to your situation.

avidcat
02-10-2006, 08:50 PM
Ooops didn't mean it that way.

Actually I found some help over on an html board, someone rewrote the script for me to use.

thanks, I have used the scripts on Dynamic Drive for the last couple years. Great Site.

Thanks,
Nick

Twey
02-10-2006, 09:09 PM
I think that sticky ought to be divided into two to prevent confusion.