On 29 Jan 2009, at 16:18, Anjanesh wrote:

> I need to trigger a 'change' event for a 'select' element.
>
> alert($($(elem).parentNode)); // shows [Object HTMLSelectElement]
> $($(elem).parentNode).fire('change'); // How do I indicate which
> option value to change to ?
>
> But the fire() doesnt work. But no JS errors either.


 From http://prototypejs.org/api/element/fire :
Element#fire does not support firing native events. All custom event  
names must be namespaced (using a colon). This is to avoid custom  
event names conflicting with non-standard native DOM events such as  
mousewheel and DOMMouseScroll.

What you want to to, is set the selectedIndex value from the <select>  
element as is documented at http://www.w3schools.com/htmldom/dom_obj_select.asp
selectedIndex needs to be an integer. If you want to select it by  
value, then you'll need to loop the values and when you find the right  
one, check what index it has (selectedIndex is a getter and a setter)  
and set it to that index.


Best regards

Peter De Berdt


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to