View Full Version : Error in code
nibbon
10-07-2008, 09:06 PM
I wasn't entirely sure where to put this but I figured html was general enough a place. I have an error in my code that I can't figure out. It works fine in firefox but it does not work in IE. I have copied all the related code below. The main objective of the code is to make a drop down menu choice change a picture elsewhere on the page.
Error reads
"Line 380
Object doesn't support this property or method"
Line 380 is the bracket "{" after the line "function imgswap()"
<script type="text/javascript">
/************************************************************
* Script by : Raymond Angana
* Title: Dropdown Based Picture w/ Captions
* First seen in AFHB2000.com
* rangana in AHFB2000.com
* Created June 5, 2008
* This notice must stay intact
/**********************************************************/
function imgswap()
{
bp=('http://xxxxx.xxx/'), //base url of your images
imgnum=2, //Number of your images. This should match on your comboboxes options.
thumb=document.getElementById('thumb'), //id of your image that will be changing
combobox=document.getElementById('selection'); // id of your combobox.
combobox.onchange=function()
{
thumb.src=bp+'picture'+this.value+'.jpg';
description.innerHTML=caption[this.value];
}
}
</script>
magicyte
10-07-2008, 09:13 PM
here is some changed up code. it might work:
<script type="text/javascript">
/************************************************************
* Script by : Raymond Angana
* Title: Dropdown Based Picture w/ Captions
* First seen in AFHB2000.com
* rangana in AHFB2000.com
* Created June 5, 2008
* This notice must stay intact
/**********************************************************/
function imgswap()
{
bp=('http://xxxxx.xxx/'), //base url of your images
imgnum=2, //Number of your images. This should match on your comboboxes options.
thumb=document.getElementById('thumb'), //id of your image that will be changing
combobox=document.getElementById('selection'); // id of your combobox.
combobox.onchange=function()
{
thumb.src=bp+'picture'+this.value+'.jpg';
document.getElementById('description').innerHTML=caption[this.value];
};
}
</script>
nibbon
10-07-2008, 09:21 PM
I tried the changes and got the same error. Tested it anyway and it still works in firefox but not in IE.
here is some more code related to this function:
I had to fix an earlier problem by putting the imgswap() into the onload of the body.
<body class="thrColAbs" onload="MM_preloadImages('abouton.gif','teamon.gif','productson.gif','contacton.gif','forumon.gif','picture1.jpg','picture2.jpg'), imgswap()">
and the drop down menu that changes it:
<label>Select Color:</label>
<select id="selection">
<option value="1">Black</option>
<option value="2">Pink</option>
</select>
and the picture that is being changed:
<img src="http://xxxx.xxx/picture1.jpg" alt="brush" name="thumb" width="225" height="425" id="thumb">
Thanks for trying to help
rangana
10-08-2008, 12:43 AM
Err, the name and username looks familiar ;)
Anyway, there's nothing wrong with the code, what's erroneous is this:
<body class="thrColAbs" onload="MM_preloadImages('abouton.gif','teamon.gif','productson.gif','contacton.gif','forumon.gif','picture1.jpg','picture2.jpg'), imgswap()">
...replace highlighted with semi-colon ( ; )
You might also want to remove highlighted:
combobox.onchange=function()
{
thumb.src=bp+'picture'+this.value+'.jpg';
description.innerHTML=caption[this.value];
}
It seemed to me that you are not using it (base on the markup provided)
Hope that helps.
nibbon
10-08-2008, 01:07 AM
unfortunately the recommended changes did not seem to work :(
I did preview it in IE (From dreamweaver) instead of just using IE tab and the error reads a little differently this way:
instead of line 380 it states
Line: 381
Char: 2
same error
code: 0
As for my username, i use it for everything - many message boards and games (so that may be the way you recognize it, in the event we have crossed paths in the past).
Anyway, with your changes it does still work in firefox (I was wondering what that extra line of code did [and my saying is, if you do not know, leave it in]). The semi-colon change, similarly, seems to have changed nothing.
Thank you for trying to help though :)
rangana
10-08-2008, 01:12 AM
I mean, that of the notice.
Anyway, add highlighted:
var bp=('http://xxxxx.xxx/'), //base url of your images
When you receive an error, try to remove that part I pointed out to you on post#4, unless you're using it in some special manner.
Hope that helps.
nibbon
10-08-2008, 01:37 AM
I love you, you did it, you are awesome :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.