[Ror-es] ubicarme en el primer campo

William Betancur ruby-forum-incoming at andreas-s.net
Sat Jul 7 16:41:15 GMT 2007


Solucion para todos los formularios de tu aplicacion:

en layouts/apllication.rhtml agrego codigo javascript

<script language="JavaScript">
<!-- Begin
  function setFocus() {
  if (document.forms.length > 0) {
     var field = document.forms[0];
     for (i = 0; i < field.length; i++) {
         if ((field.elements[i].type == "text") || 
(field.elements[i].type == "textarea")
            || (field.elements[i].type.toString().charAt(0) == "s")) {
            document.forms[0].elements[i].focus();
            break;
         }
     }
  }
}
// End -->
</script>
</head>
<body OnLoad="setFocus()">
<% if flash[:notice] %>
   <span class="notice">
     <%=h flash[:notice] %>
   </span>
<% end %>
<%= render_stickies %>
<%= @content_for_layout %>

</body>
</html>

-- 
Posted via http://www.ruby-forum.com/.


More information about the Ror-es mailing list