Jump to content

autotabbing


OriginalBoy

Recommended Posts

<html>
<head>
  <script type="text/javascript">
    function moveNext(fieldObj, nextFieldID)
    {
        if (fieldObj.value.length >= fieldObj.maxLength)
        {
            document.getElementById(nextFieldID).focus();
        }
    }
  </script>
</head>

<body>

Phone:
(<input type="text" maxlength="3" size="2" id="area_code" name="area_code" onkeyup="moveNext(this, 'prefix');">)
<input type="text" maxlength="3" size="2" id="prefix" name="prefix" onkeyup="moveNext(this, 'phone');"> -
<input type="text" maxlength="4" size="3" id="phone" name="phone" onkeyup=""><br>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/114302-autotabbing/#findComment-587940
Share on other sites

<td>Home Phone:
              <td>
                <input type="hidden" name="homephone" id="homephone" />
                (<input type="text" name="hphone1" size="3" maxlength="3" onkeyup="moveNext(this, 'hphone2');">)-<input type="text" name="hphone2" size="3" maxlength="3" onkeyup="moveNext(this, 'hphone3');">-<input type="text" name="hphone3" size="4" maxlength="4" onkeyup=""></td>
	</tr>

 

I put that in and then the top thing at the top of my page and its not worked. What have I done wrong?

Link to comment
https://forums.phpfreaks.com/topic/114302-autotabbing/#findComment-587951
Share on other sites

The code I provided requires you to pass the ID of the field to move to. You didn't set IDs for the fields:

<td>Home Phone:
              <td>
                <input type="hidden" name="homephone" id="homephone" />
                (<input type="text" name="hphone1" size="3" maxlength="3" onkeyup="moveNext(this, 'hphone2');">)-<input type="text" name="hphone2" id="hphone2" size="3" maxlength="3" onkeyup="moveNext(this, 'hphone3');">-<input type="text" name="hphone3" id="hphone3" size="4" maxlength="4" onkeyup=""></td>
	</tr>

Link to comment
https://forums.phpfreaks.com/topic/114302-autotabbing/#findComment-588139
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.