Don't assume we are the first form on the page
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 7 May 2008 16:48:15 +0000 (16:48 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 7 May 2008 16:48:15 +0000 (16:48 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13106 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/login.php

index 226ccd8a2d9c17c2a01699419da1e0a1bbe6d57c..ef769f85585b3f3e1c71f58e3e75ff5c0636142d 100644 (file)
@@ -71,11 +71,11 @@ $header = "<script type=\"text/javascript\">\n" .
           "  function squirrelmail_loginpage_onload() {\n".
           "    if (alreadyFocused) return;\n".
           "    var textElements = 0; var i = 0;\n".
-          "    for (i = 0; i < document.forms[0].elements.length; i++) {\n".
-          "      if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
+          "    for (i = 0; i < document.login_form.elements.length; i++) {\n".
+          "      if (document.login_form.elements[i].type == \"text\" || document.login_form.elements[i].type == \"password\") {\n".
           "        textElements++;\n".
           "        if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
-          "          document.forms[0].elements[i].focus();\n".
+          "          document.login_form.elements[i].focus();\n".
           "          break;\n".
           "        }\n".
           "      }\n".
@@ -155,7 +155,7 @@ $oTemplate->assign('login_extra', $login_extra, FALSE);
 
 //FIXME: need to remove *ALL* HTML from this file!
 echo '<body onload="squirrelmail_loginpage_onload()">'."\n";
-echo '<form action="redirect.php" method="post" onsubmit="document.forms[0].js_autodetect_results.value='. SMPREF_JS_ON .'">'."\n";
+echo '<form name="login_form" id="login_form" action="redirect.php" method="post" onsubmit="document.login_form.js_autodetect_results.value='. SMPREF_JS_ON .'">'."\n";
 do_hook('login_top', $null);
 
 $oTemplate->display('login.tpl');