terencexuan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jun-28 07:36 UTC
problem with getElements, getInputs in Prototype
I''ve following code: <script src="javascripts/prototype.js" type="text/javascript"></ script> <form id="user"> <input type="text" id="username" name="username" value="abc" /> </form> <script type="text/javascript"> var form = $(''user''); var a = form.getElements(); alert(a); </script> what pops up is [object] in IE, and [object HTMLInputElement] in Firefox what went wrong??? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It doesn''t look like anything is wrong. Why are you so sure something has failed? The implicit "toString()" that is called when you alert echoes the values in the array. (In Firefox, they''re comma separated, Dunno about IE--I''m on a Mac at the moment.) javascript: alert([1,2,3]); When the toString() for the input element is called, IE produces the unhelpful [object], while Firefox is more explicit on the object type. Both are correct. So, what''s the problem? TAG On Jun 28, 2007, at 1:36 AM, terencexuan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > I''ve following code: > > <script src="javascripts/prototype.js" type="text/javascript"></ > script> > > <form id="user"> > <input type="text" id="username" name="username" value="abc" /> > </form> > > <script type="text/javascript"> > var form = $(''user''); > var a = form.getElements(); > alert(a); > </script> > > what pops up is [object] in IE, and [object HTMLInputElement] in > Firefox > > what went wrong??? > > Thanks. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---