How to give a form a name

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…

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()” %>

Sorry one caveat… That assumes that your using the prototype library

if not

<%= javascript_tag “getElementById(‘id_of_field’).focus()” %>

<%= start_form_tag( {:action => “index”}, {:id => “myformid”}) %>

Try that bad boy out.

  • J