kbilbee-bhBtkFhEHeNHi16/csmv5pqQE7yCjDx5@public.gmane.org
2007-Feb-13 18:11 UTC
Ajax Dynamic form fields
I am using Ajax.Request to get preformatted html with new form fields to be added to my page. I have an issue where the new form fields can not be accessed by using $F() or $().value. I can access the new form fields by using document.forms[0].elements[].value Any idea why prototypejs seems to be tripping on this? prototypejs is a great framework for quickly getting javascript and Ajax requests functioning. I reviewed the documentation for about two hours and have been able to create a dynamic order entry form. Which previously would have taken about 3 times tha amount of time. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Do you have an example? My initial guess would be that you failed to assign an ID to the form elements that you are inserting with your Ajax.Request assuming you are trying to manually access the value of the form element by passing it''s ID in to $() or $F() as a string. -E On 2/13/07, kbilbee-bhBtkFhEHeNHi16/csmv5pqQE7yCjDx5@public.gmane.org <kbilbee-bhBtkFhEHeNHi16/csmv5pqQE7yCjDx5@public.gmane.org> wrote:> > I am using Ajax.Request to get preformatted html with new form fields > to be added to my page. I have an issue where the new form fields can > not be accessed by using $F() or $().value. I can access the new form > fields by using document.forms[0].elements[].value > > Any idea why prototypejs seems to be tripping on this? > > prototypejs is a great framework for quickly getting javascript and > Ajax requests functioning. I reviewed the documentation for about two > hours and have been able to create a dynamic order entry form. Which > previously would have taken about 3 times tha amount of time. > > > > >-- Eric Ryan Harrison --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey there, kbilbee-bhBtkFhEHeNHi16/csmv5pqQE7yCjDx5@public.gmane.org a écrit :> I am using Ajax.Request to get preformatted html with new form fields > to be added to my page. I have an issue where the new form fields can > not be accessed by using $F() or $().value. I can access the new form > fields by using document.forms[0].elements[].valueHmmm. For starters, are you certain your fields have proper idattributes, and you''re using the IDs, not the NAMEs, to get at them using $F? On a side note, be aware that if you registered a Form.EventObserver on the global form and are adding fields later on, the event observer will *not* detect changes on those: that''s because when initially created, it spawned individual Form.Element.EventObservers for every field in there *at the time*, and relies only on those. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
kbilbee-bhBtkFhEHeNHi16/csmv5pqQE7yCjDx5@public.gmane.org
2007-Feb-13 19:10 UTC
Re: Ajax Dynamic form fields
You were correct the id tag was missing. I guess I missed that part in the docs. So for radio buttons and check boxes do I use $ (''formid'').getInputs(''radio'', radioname) and then iterate through each returned object to see if it has been selected? Or is there already a method in prototypejs to do this form me? On Feb 13, 10:45 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey there, > > kbil...-bhBtkFhEHeNHi16/csmv5pqQE7yCjDx5@public.gmane.org a écrit : > > > I am using Ajax.Request to get preformatted html with new form fields > > to be added to my page. I have an issue where the new form fields can > > not be accessed by using $F() or $().value. I can access the new form > > fields by using document.forms[0].elements[].value > > Hmmm. For starters, are you certain your fields have proper id> attributes, and you''re using the IDs, not the NAMEs, to get at them > using $F? > > On a side note, be aware that if you registered a Form.EventObserver on > the global form and are adding fields later on, the event observer will > *not* detect changes on those: that''s because when initially created, it > spawned individual Form.Element.EventObservers for every field in there > *at the time*, and relies only on those. > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
kbilbee-bhBtkFhEHeNHi16/csmv5pqQE7yCjDx5@public.gmane.org a écrit :> So for radio buttons and check boxes do I use $ > (''formid'').getInputs(''radio'', radioname) and then iterate through each > returned object to see if it has been selected? Or is there already a > method in prototypejs to do this form me?If you need to filter on a specific radio field name, your code sounds good enough. I think it''s going to be in the same ballpark as using the $$ method: $$(''#formId input[type=radio][name=radioName]'') What do you need to know about the resulting array of radio buttons? Whether one was selected? Or which one was selected? Look at the any and find methods of Enumerable, respectively. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---