I don't know if anyone has solved the issue yet, but the problem is on this
line:
var image_id = this.get('id');
You are getting the id from the LI element, while on the HTML you have the
id stored on the img element.
Change it to:
var image_id = this.getElement('img').get('id');
That should work.
On Tue, May 26, 2009 at 12:21 AM, Judas Priest <[email protected]> wrote:
>
> Hello everybody.
>
> I have a simple piece of code, which, based on users click event, the
> 'src' attribute of an image is changed with another generated using
> the 'id' of the image element. Every thing is working just fine in all
> major browser with the exception (as many times before) IE version 6.
>
> The JavaScript code is:
> $$('.chg_src').addEvent('click', function(){
> var image_id = this.get('id');
> $('img_container').setProperty('src',
> 'images/' + image_id
> +'.png');
> });
> And the HTML code:
> <img class="left" id="img_container" src="images/nl1.png" />
> <div id="imgs_container" class="right">
> <ul id="thumbs">
> <li><img class="chg_src" id="nl1" src="images/nl1_thumb.png"
> /></li>
> <li><img class="chg_src" id="nl2" src="images/nl2_thumb.png"
> /></li>
> <li><img class="chg_src" id="nl3" src="images/nl3_thumb.png"
> /></li>
> <li><img class="chg_src" id="nl4" src="images/nl4_thumb.png"
> /></li>
> <li><img class="chg_src" id="nl5" src="images/nl5_thumb.png"
> /></li>
> </ul>
> </div>
>
> The problem is that nothing is happening in IE 6 when the thumb image
> is clicked. I use a stand alone version of IE 6(and it has some limits
> in functionality). I presume that somehow the id of the image is not
> passed to the new 'src' attribute. "this.get('id')" is taking the id
> of the image; I've putted an "alert" after the code line and the
> message shows correctly the image id.
> A day before the error thrown was of type :"Object expected", but
> today I can't see the error message anymore.
>
> Any help will be very appreciated.
>
> Thank you,
> Cristian Nistor