Using a <%= form_tag ... %>, how do I give a form a name, so that I can reference it with javascript? I sure can''t figure this out from the docs... Thanks, Shelby PS - what I am trying to do is just have the focus in the first form field when the form is loaded. There has to be an easy way to do this, but I can''t figure it out... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060615/b89c80d3/attachment.html
Hi Shelby, I don''t think the form has an onload event to tap into. You can give a form a name by <%= form_tag {}, {:name => ''my_name'' } %> .... or alternatively you could just put in some javascript inline below the form <%= javascript_tag "$(''the_id_of_the_field_to_focus'').focus()" %> On 6/15/06, Shelby Westman <shelby.westman@gmail.com> wrote:> > Using a <%= form_tag ... %>, how do I give a form a name, so that I can > reference it with javascript? I sure can''t figure this out from the docs... > > Thanks, > Shelby > > PS - what I am trying to do is just have the focus in the first form field > when the form is loaded. There has to be an easy way to do this, but I > can''t figure it out... > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060615/57870678/attachment.html
Sorry one caveat.. That assumes that your using the prototype library if not <%= javascript_tag "getElementById(''id_of_field'').focus()" %> On 6/15/06, Daniel N <has.sox@gmail.com> wrote:> > Hi Shelby, > > I don''t think the form has an onload event to tap into. You can give a > form a name by > <%= form_tag {}, {:name => ''my_name'' } %> > .... > > or alternatively you could just put in some javascript inline below the > form > > <%= javascript_tag "$(''the_id_of_the_field_to_focus'').focus()" %> > > On 6/15/06, Shelby Westman < shelby.westman@gmail.com> wrote: > > > Using a <%= form_tag ... %>, how do I give a form a name, so that I can > reference it with javascript? I sure can''t figure this out from the docs... > > Thanks, > Shelby > > PS - what I am trying to do is just have the focus in the first form field > when the form is loaded. There has to be an easy way to do this, but I > can''t figure it out... > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060615/12b0cd35/attachment.html
<%= start_form_tag( {:action => "index"}, {:id => "myformid"}) %> Try that bad boy out. - J On 6/14/06, Shelby Westman <shelby.westman@gmail.com> wrote:> > Using a <%= form_tag ... %>, how do I give a form a name, so that I can > reference it with javascript? I sure can''t figure this out from the docs... > > Thanks, > Shelby > > PS - what I am trying to do is just have the focus in the first form field > when the form is loaded. There has to be an easy way to do this, but I > can''t figure it out... > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060615/c509e4e8/attachment.html