Using Prototype, just do Form.focusFirstElement();
For more Prototype help see:
Cheers, Jonathan.
Using Prototype, just do Form.focusFirstElement();
For more Prototype help see:
Cheers, Jonathan.
Someone asked how to set the focus on the first form element. Jonathan
Viney answered:
Using Prototype, just do Form.focusFirstElement();
For more Prototype help see:
http://www.sergiopereira.com/articles/prototype.js.html
Cheers, Jonathan.
Thanks. However, I would like more detail. This javascript function
takes as an argument the name of the form. I created my form using this
line:
<%= start_form_tag(:action => “createnewdocument”) %>
It shows up in HTML as follows:
So, two related questions:
Thanks.
Dan,
Take a look @ http://api.rubyonrails.com/classes/ActionView/Helpers/
FormTagHelper.html#M000403 which is the docs for the start_form_tag
helper. It’s a bit confusing, but you can pass in the options as the
second parameter, and the options are where you can set all the other
html attributes.
Instead of
<%= start_form_tag(:action => “createnewdocument”) %>
do
<%= start_form_tag( { :action => “createnewdocument”) }, { :id =>
“MyFormName” } %>
Note the {}'s around the :action, which is the ‘url_for_options’ part
of the helper.
‘MyFormName’ is the id that you’d pass to the other function.
Chris Nolan.ca
http://kekova.ca/
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs