The following alert($(''city'').value) returns undefined. The alert($ (''zip'').value) returns ''zip'' and $(''city'').update works fine also. Any help word be appreciated. Ken <HTML> <HEAD> <title>Css Call List</title> <script language="Javascript" src="includes/scripts/prototype/ prototype.js"></script> <script language="javascript" type="text/javascript"> function handleCity() { $(''city'').update(''Dallas''); alert($(''city'').value); alert($(''zip'').value); } </script> </HEAD> <BODY > <form action="post"> <p> ZIP Code: <input type="text" size="5" id="zip" onChange"handleCity();"/> </p> </form> <div id="city">Houston</div> </BODY> </HTML> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
To update element''s context use .update(), to get value attribute (not context) of an input, use .getValue() or $F(''element_id''). Setting value was introduced in 1.6 - $(''element_id'').setValue(''foo'') --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
developer-P5Ep+WoDybrQT0dZR+AlfA@public.gmane.org
2007-Nov-18 01:12 UTC
Re: Prototype $(''id'').value problem?
$(''city'') is a div, not an input. A div doesn''t have a value. If you want to get what is inside of it, try $(''city'').innerHTML. Trevan kenq wrote:> The following alert($(''city'').value) returns undefined. The alert($ > (''zip'').value) returns ''zip'' and $(''city'').update works fine also. > Any help word be appreciated. > > Ken > > > <HTML> > <HEAD> > <title>Css Call List</title> > <script language="Javascript" src="includes/scripts/prototype/ > prototype.js"></script> > <script language="javascript" type="text/javascript"> > function handleCity() { > $(''city'').update(''Dallas''); > alert($(''city'').value); > alert($(''zip'').value); > } > </script> > </HEAD> > <BODY > > <form action="post"> > <p> ZIP Code: <input type="text" size="5" id="zip" onChange> "handleCity();"/> > </p> > </form> > <div id="city">Houston</div> > </BODY> > </HTML> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 17, 2007 12:31 PM, kenq <nniuqnek-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The following alert($(''city'').value) returns undefined. The alert($ > (''zip'').value) returns ''zip'' and $(''city'').update works fine also.Non-form elements don''t have a "value" attribute, so $(''city'')--or $F(''city'') for that matter--don''t have anything to return. Since $(''zip'') _is_ a form element (an input), it returns the value of the input. Update works because update''s not working on the value of the element, it''s working on the children of the element, that is, the element''s contents--but those contents aren''t the value of the element. If you want to access what''s in $(''city''), you''ve got to do something like $(''city'').firstChild.nodeValue, or just $(''city'').innerHTML. :Dan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---