I have a select list of items and I want to highlight the background
color of the select list when the element gets focus.
I have the following function to simply set the background color of an
object:
function hilite(event)
{
var obj = Event.element(event);
if (obj) {
$(obj).setStyle({backgroundColor: ''#FFFFC8''});
}
}
Here is the function I call at window load time...
function observeSelectList(el_name)
{
var el;
el = $(el_name);
if (el) {
Event.observe (el, ''blur'', delite_textbox);
Event.observe (el, ''keypress'', hilite_textbox);
Event.observe (el, ''focus'', hilite_textbox);
}
}
I also do the following on window load for the select list using...
function myload()
{
initCommon();
observeSelectList("lanspeed");
}
Event.observe(window, ''load'', myload);
Now, when I include the Event.observe call for the ''focus''
event, I
click in that select list and the background color is correctly
changed. However, the drop down list does not appear. If I click on
the element two more times, the drop down list appears.
If I remove the event.observe call for the ''focus'' event, the
select
list drop down appears the first time I click in the select elemet -
like it is supposed to. Of course, the background color does not
change - which is what I want to do with the Event.observe
''focus''
function.
Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---