Einzelnen Beitrag anzeigen

Benutzerbild von c113plpbr
c113plpbr

Registriert seit: 18. Nov 2003
Ort: localhost
674 Beiträge
 
Delphi 2005 Professional
 
#3

Re: [html/javascript] Formular: Tab 'ausführen'

  Alt 28. Jun 2004, 14:52
Die gleiche idee hatte ich auch ... nur mir stellt sich hier nun ein Problem:
Code:
<html>
<head>
<script language="javascript">
<!--
function focusnext(comp)
{
   var i = 0;
   if(comp.value.length == comp.maxLength)
   {
      while (i < 100)
      {
         if(comp.form.elements[i])
         {
            alert('tabindex: ' + comp.form.elements[i].tabindex);
            if(comp.form.elements[i].tabindex == comp.tabindex + 1)
            {
               comp.form.elements[i].focus();
               break;
            }
         }
         else
         {
            alert('fehler: kein entsprechendes element gefunden!');
            break;
         }         
         i++;
      }
   }
}
//-->
</script>
</head>
<body>
  <form name="form1" method="post" action="">
    <input type="text" name="textfield1" onkeypress="focusnext(this);" maxlength="2" tabindex="1">
    <input type="text" name="textfield2" onkeypress="focusnext(this);" maxlength="3" tabindex="3">
    <input type="text" name="textfield3" onkeypress="focusnext(this);" maxlength="1" tabindex="2">
    <input type="text" name="textfield4" onkeypress="focusnext(this);" maxlength="5" tabindex="5">
    <input type="text" name="textfield5" onkeypress="focusnext(this);" maxlength="4" tabindex="4">
   


    <input type="button" name="Submit" value="Submit">
  </form>
</body>
</html>
problematisch ist dabei diese Zeile:
Code:
if(comp.form.elements[i].tabindex == comp.tabindex + 1)
weder "comp.form.elements[i].tabindex" noch "comp.tabindex" gibt einen Wert zurück (wie man aus dem alert schliessen kann), was zum problem wird. Weis jemand wie ich die entsprechende werte doch noch herausfinden kann?
Philipp
There is never enough time to do all the nothing you want.
*HABENWILL*
  Mit Zitat antworten Zitat