This first thing to do would be some simple tracing. Place an alert within your observe method to make sure that event is even firing as you think it is.
Also, you don't even need to do the Event.element stuff here, as you already have the reference to the element (focusableField), right?... $('input1').activate(); $$('.focusable').each(function(focusableField){ Event.observe(focusableField, 'change', function(event){ alert("change is firing correctly"); focusableField.activate(); }); }); On 6/5/07, WiB <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > I'm trying to understand why the following code doesnt work... > > > > ---------------------------------------------------------------------------------------- > <html> > <head> > <title>blabla</title> > <script type="text/javascript" src="prototype.js"></script> > </head> > <body> > <form action="bllalba"> > <table> > <tr> > <td>Input1</td> > <td><input id="input1" type="text" name="bla1" /></td> > <td>Input2</td> > <td><input id="input2" class="focusable" type="text" > name="bla2" /></ > td> > </tr> > > </table> > > > > > <script type="text/javascript"> > $('input1').activate(); > $$('.focusable').each(function(focusableField){ > Event.observe(focusableField, 'change', function(event){ > var elt=Event.element(event); > //elt.activate(); > $(elt.id).activate(); > }); > }); > > </script> > > > </form> > </body> > </html> > > > ---------------------------------------------------------------------------------------- > > > Basically, I have two textfields here. On changing the value of > textfield 2, there will be a validation performed (not shown on code > above, for simplicity). > When this validation failed, the same textfield should be selected > (highlighted, and typing anything should replace the content of that > textfield). According to the documentation, I can simply > call activate(). But it didnt work for me in the code above (it works > fine for 'input1', but not the one inside the > Event.observe()). > > > Could anyone pinpoint to me where I had done wrong? I suspect it has > something to do with my usage of Event.element() method. > > > Thanks! > > > Alex. > > > > > -- Ryan Gahl Principal, Manager Nth Penguin, LLC - Consulting http://www.nthpenguin.com -- Software Architect WebWidgetry.com / MashupStudio.com Future Home of the World's First Complete Web Platform -- Inquire: 1-262-951-6727 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---