onChange not sending the desired value, minor debug assistance needed

Attached code snippet.

When the user changes the value of the <SELECT> element, I want to send the VALUE of the selected element (i.e., https://secure.url.com, etc.) to the changeimage function, which in turn displays a different image in the <IMG> tag identified by "imagea".

The way I have it now, it is returning something like "[object%20HTMLSelectElement]" to the function instead.

I'm sure there is just something that isn't quite right that is very easy to fix. Thanks!
<SELECT NAME="lm_image" SIZE="36" ONCHANGE="changeimage(this)">
	<OPTION VALUE="https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C">159P.jpg
	<OPTION VALUE="https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C159P%2Ejpg">4-drawer-dresser_lg.jpg
	<OPTION VALUE="https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C159P%2Ejpg">cchaydencan.jpg
	<OPTION VALUE="https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C159P%2Ejpg">kr155.jpg
	<OPTION VALUE="https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C159P%2Ejpg">NApinktoilesw_th.jpg
	<OPTION VALUE="https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C159P%2Ejpg">widgeonfleececoat.jpg</SELECT>
 
<SCRIPT LANGUAGE="JavaScript"><!-- Hide from old browsers
	if (document.images) {
 
	var imageaoff = new Image()
	imageaoff.src = "https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C159P%2Ejpg"
	}
 
	function changeimage(newUrl) {
	if (document.images)
	document.imagea.src = eval(newUrl)
	}
// Stop hiding from old browsers -->
</SCRIPT>
 
<IMG NAME="imagea" SRC="https://secure.url.com/livemerchant/images_thumb.asp?filename=D%3A%5Ctathamstamps%2Ecom%5Clm%5Fscans%5C159P%2Ejpg" BORDER="0">

Open in new window

Brad BansnerWeb DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

und3athCommented:
newUrl is the whole object!!! You have to use newUrl.value
document.imagea.src = eval(newUrl.value);

Open in new window

0
Brad BansnerWeb DeveloperAuthor Commented:
OK, rightly so. I tried that, but now when I change the menu nothing happens at all. Before it would change to a "broken image" icon, now nothing. Is there something else in there that isn't quite right?
0
Brad BansnerWeb DeveloperAuthor Commented:
I'm tracking what is being passed to the function, and its saying "undefined". So I'm wondering if where it says ONCHANGE="changeimage(this)" is the problem? Will that properly pass the value of the <OPTION> element that is selected?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

und3athCommented:
my modification
<SELECT NAME="lm_image" SIZE="36" ONCHANGE="changeimage(this)">
        <OPTION VALUE="1.gif">159P.jpg
        <OPTION VALUE="2.gif">4-drawer-dresser_lg.jpg
        <OPTION VALUE="3">cchaydencan.jpg
        <OPTION VALUE="4">kr155.jpg
        <OPTION VALUE="5">NApinktoilesw_th.jpg
        <OPTION VALUE="6">widgeonfleececoat.jpg</SELECT>
 
<SCRIPT LANGUAGE="JavaScript">
        if (document.images) {
 
        var imageaoff = new Image();
        imageaoff.src = "";
        }
 
        function changeimage(newUrl) {
        if (document.images)
        document.imagea.src = newUrl.value;
        }
 
</SCRIPT>
 
<IMG NAME="imagea" SRC="" BORDER="0">

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hieloCommented:
on what you posted originally, try:
        function changeimage(newUrl) {
        	if (document.images)
        		document.images.imagea.src = newUrl.value
        }

Open in new window

0
Brad BansnerWeb DeveloperAuthor Commented:
I believe its working now, thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.