Hi Guys, Maybe this is a stupid question, but I am confused at the moment. The $F() function is a handy shortcut to get the value of the an input field. So, doing something like $F(''name'') is equivalent to document.formname.name.value which is pretty cool. Now, what if I have 2 forms on the page, that same field name "name"? What would $F return? It does not take the form name - right? Thanks, Mandy.
I also have a question about $F() while we are on the topic.. am I correct in assuming that $F() is read only? I have never been able to set a forms elements value using $F(''name'')="Alex" I have always had to use $(''name'').value = "Alex" ______________________________________________________________________ Alex Duffield . Principal . InControl Solutions . http:// www.incontrolsolutions.com On 2-Mar-06, at 8:22 AM, Maninder, Singh wrote:> Hi Guys, > > Maybe this is a stupid question, but I am confused at the moment. > > The $F() function is a handy shortcut to get the value of the an > input field. > > So, doing something like $F(''name'') is equivalent to > document.formname.name.value which is pretty cool. > > Now, what if I have 2 forms on the page, that same field name "name"? > What would $F return? It does not take the form name - right? > > Thanks, > Mandy. > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Tried $F(''name'').value = "foo"; ? I''d assume $F returns the first form element it finds. -Rob Alex Duffield wrote:> I also have a question about $F() while we are on the topic.. > > am I correct in assuming that $F() is read only? > > I have never been able to set a forms elements value using > > $F(''name'')="Alex" > > I have always had to use > > $(''name'').value = "Alex" > > > ______________________________________________________________________ > > *Alex Duffield* *.* *Principal* *.* *InControl Solutions* *.* > *http://www.incontrolsolutions.com* <http://www.incontrolsolutions.com/> > > > > > On 2-Mar-06, at 8:22 AM, Maninder, Singh wrote: > >> Hi Guys, >> >> Maybe this is a stupid question, but I am confused at the moment. >> >> The $F() function is a handy shortcut to get the value of the an input >> field. >> >> So, doing something like $F(''name'') is equivalent to >> document.formname.name.value which is pretty cool. >> >> Now, what if I have 2 forms on the page, that same field name "name"? >> What would $F return? It does not take the form name - right? >> >> Thanks, >> Mandy. >> _______________________________________________ >> Rails-spinoffs mailing list >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
The $F(id) function returns the value of the form field where the id is the id of the form field. example mark up <input type="text" name="foo" id="foo_id" value="123" /> javascript var fooValue = $F(''foo_id''); Now fooValue == "123" should return true. It does different things depending on what type of form field you are asking for the value of (i.e. select, checkbox, radio, textare). But it is always a read only string from my understanding. I think $F just masks to Form.Element.getValue so you can look at that function in protoype if you want for more details. Nicholas On 3/2/06, Robin Haswell <rob-gyMb1R/nBgNh8AIihN9Rc9BPR1lH4CV8@public.gmane.org> wrote:> Tried $F(''name'').value = "foo"; ? > > I''d assume $F returns the first form element it finds. > > -Rob > > Alex Duffield wrote: > > I also have a question about $F() while we are on the topic.. > > > > am I correct in assuming that $F() is read only? > > > > I have never been able to set a forms elements value using > > > > $F(''name'')="Alex" > > > > I have always had to use > > > > $(''name'').value = "Alex" > > > > > > ______________________________________________________________________ > > > > *Alex Duffield* *.* *Principal* *.* *InControl Solutions* *.* > > *http://www.incontrolsolutions.com* <http://www.incontrolsolutions.com/> > > > > > > > > > > On 2-Mar-06, at 8:22 AM, Maninder, Singh wrote: > > > >> Hi Guys, > >> > >> Maybe this is a stupid question, but I am confused at the moment. > >> > >> The $F() function is a handy shortcut to get the value of the an input > >> field. > >> > >> So, doing something like $F(''name'') is equivalent to > >> document.formname.name.value which is pretty cool. > >> > >> Now, what if I have 2 forms on the page, that same field name "name"? > >> What would $F return? It does not take the form name - right? > >> > >> Thanks, > >> Mandy. > >> _______________________________________________ > >> Rails-spinoffs mailing list > >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- DCRails.com || Making the Metrorail fun!
On Thursday 02 March 2006 08:22, Maninder, Singh wrote:> Hi Guys, > > Maybe this is a stupid question, but I am confused at the moment. > > The $F() function is a handy shortcut to get the value of the an input > field. > > So, doing something like $F(''name'') is equivalent to > document.formname.name.value which is pretty cool.no, it''s actually more like: document.getElementById(''name'').value> Now, what if I have 2 forms on the page, that same field name "name"? > What would $F return? It does not take the form name - right?it doesn''t work based off the ''name'' attribute of the form field, it works based off the element''s id. -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Which *should* be unique :-) On 3/2/06, Jeremy Kitchen <kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org> wrote:> > On Thursday 02 March 2006 08:22, Maninder, Singh wrote: > > Hi Guys, > > > > Maybe this is a stupid question, but I am confused at the moment. > > > > The $F() function is a handy shortcut to get the value of the an input > > field. > > > > So, doing something like $F(''name'') is equivalent to > > document.formname.name.value which is pretty cool. > > no, it''s actually more like: > document.getElementById(''name'').value > > > Now, what if I have 2 forms on the page, that same field name "name"? > > What would $F return? It does not take the form name - right? > > it doesn''t work based off the ''name'' attribute of the form field, it works > based off the element''s id. > > -Jeremy > > -- > Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org > > In the beginning was The Word and The Word was Content-type: text/plain > -- The Word of Bob. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs