There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer audio black screen boot bsod computer connection crash css dell display driver drivers email error ethernet excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware network networking nvidia outlook outlook 2003 outlook express partition printer problem router slow software sound trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Changing Textfields in JavaScript


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
PiTCH BLAK's Avatar
Member with 32 posts.
 
Join Date: Aug 2004
Experience: Intermediate
10-Jun-2006, 02:21 AM #1
Unhappy Changing Textfields in JavaScript
Am desigining a webpage, and part of the requirements is to have a 9 digit tax file number input box, laid out so the number can be broken up into 3 sections of 3 digits.

So I figure the easiest way to do this for the user and myself is to make 3 textfields.

Code:
<input type="text" name="tfTFN1" size="1" MAXLENGTH="3" onChange="tfnMoveNext2()" />
<input type="text" name="tfTFN2" size="1" MAXLENGTH="3" onChange="tfnMoveNext3()" />
<input type="text" name="tfTFN3" size="1" MAXLENGTH="3" /></td>
Now to make this even more user-friendly, I've been trying to write a function that jumps to the next text box, like on most unlock keycodes on a lot of software.

Code:
function tfnMoveNext2()
{
	sTFN1 = document.inputForm.tfTFN1.value
	if(sTFN1.length == 3)
	{
		document.inputForm.tfTFN2.focus()
	}
}

function tfnMoveNext3()
{
	sTFN2 = document.inputForm.tfTFN2.value
	if(sTFN2.length == 3)
	{
		document.inputForm.tfTFN3.focus()
	}
}
Alas, my function does not work. Can anyone see an error in my code? Am I looking in the wrong direction with this thing?
__________________
Programming Extraordinaire... sometimes...
covert215's Avatar
Account Disabled with 2,651 posts.
 
Join Date: Apr 2006
Experience: Web Designer
10-Jun-2006, 04:26 PM #2
i'm not very good with js, but i know some basincs

are you telling it to focus on whatever your text field is called?
bpmurray's Avatar
Senior Member with 103 posts.
 
Join Date: Jun 2003
Location: Ireland
Experience: Advanced
11-Jun-2006, 12:51 PM #3
This issue is discussed at length many places. Try this: http://episteme.arstechnica.com/eve/...m/822001929731
PiTCH BLAK's Avatar
Member with 32 posts.
 
Join Date: Aug 2004
Experience: Intermediate
11-Jun-2006, 12:57 PM #4
Quote:
Originally Posted by covert215
i'm not very good with js, but i know some basincs

are you telling it to focus on whatever your text field is called?
Yes, I'm telling to focus on the next next field after the one in focus is filled.

Quote:
Originally Posted by bpmurray
This issue is discussed at length many places. Try this: http://episteme.arstechnica.com/eve/...m/822001929731
That page looks like it will help my cause a lot. Thank you.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:54 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.