Bob_Smith
(Bob Smith)
1
I'm trying to set the focus to the first (and only} field on a search
form and having no luck.
From searching with google, I came up with:
javascript_tag("Event.observe(window, 'load', function() {
var firstForm = $A(document.getElementsByTagName('search'))[0];
Form.focusFirstElement(firstForm);} );")
no response, though. Please help
Bob
hassan
(Hassan Schroeder)
2
For one thing, there is no HTML tag named "search"; you're probably
looking for an "input" ... 
Bob_Smith
(Bob Smith)
3
Found the answer. I was making it much too complicated..
$("search").focus();
did just fine
Bob
Bob_Smith
(Bob Smith)
4
or
<%= javascript_tag('$("search").focus();') %>
as part of a view..
Bob
11155
(-- --)
5
Bob Smith wrote:
or
<%= javascript_tag('$("search").focus();') %>
as part of a view..
Bob
But never do that. JavaScript works best when it's in separate files,
not mixed with HTML.
Best,