Hello,
Apologies in advance, but a newb question here:
I am using Event.observe to add a simple function to the onclick event
of an image. This works fine if i add it to each image that requires
the function using:

Event.observe($('star1'), 'click',
function(e){objRating.setRating(1)});

However, as I am adding the same event to a set of images, I would like
to iterate through a loop to do it like this:

for (var i=1; i<=5;i++){
    Event.observe($('star'+i), 'click',
function(e){objRating.setRating(i)});
}

Unfotunately this results in when you click any of the 5 images, the
number 6 is returned.

Is there any reason you can't add event.observe in a loop like this or
am i making a newb mistake?

Thanks in advance,
j


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to