Code

Updated focus
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 9 Jul 2007 08:32:21 +0000 (08:32 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 9 Jul 2007 08:32:21 +0000 (08:32 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6774 594d385d-05f5-0310-b6e9-bd551577e9d8

html/include/focus.js
ihtml/themes/default/login.tpl

index 99e73b14c1c847d0f97eeab6b77ee34b569f6f8b..710d741d5cdcca5f1af62b7427c0f32de471a5c4 100644 (file)
@@ -342,30 +342,29 @@ function adjust_width(e) {
 */
 function focus_field()
 {      
-               var i = 0;
-               while(focus_field.arguments[i] && document.getElementById(focus_field.arguments[i]).disabled == true) {
-                       i++;
-               }
-               if(focus_field.arguments[i]){
-
-                               var name                = focus_field.arguments[i];
-                               var element = document.getElementsByName(name);
-
-                               for(i = 0; i < element.length; i++) {
-                                               if(element[i].id == name && (
-                                                               element[i].type != 'none' || 
-                                                               element[i].type != 'hidden')
-                                               ) {
-                                                       element[i].blur();              
-                                                       element[i].focus();             
-                                                       break;
-                                               }
-                               }
-               }
-}
+               var i           = 0;
+               var e           = 0;
+               var found = false; 
+               var element_name = "";
+               var element =null;
 
+               while(focus_field.arguments[i] && !found){
 
+                               var tmp = document.getElementsByName(focus_field.arguments[i]); 
+                               for(e = 0 ; e < tmp.length ; e ++ ){
 
+                                               if(tmp[e].disabled != true &&  tmp[e].type != "none" && tmp[e].type != "hidden" ){
+                                                               found = true;
+                                                               element = tmp[e];
+                                               }
+                               }
+                               i++;
+               }
 
+               if(element && found){
+                               element.blur();         
+                               element.focus();                
+               }
+}
 
 // vim:ts=2:syntax
index 900c2b9197934175a1886e590e32d9491adbfb45..aab9b08b67b1b7e9866cc0fd6aee8fd712bf8f36 100644 (file)
@@ -87,7 +87,7 @@
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page
   nextfield= "{$nextfield}";
-  focus_field({$nextfield});
+  focus_field("{$nextfield}");
   -->
 </script>