Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
set focus on data entry fields
Old 10-31-2006, 12:36 AM set focus on data entry fields
Novice Talker

Posts: 5
Name: zamir
Trades: 0
i make a data entry form in asp, now i want when user enter data and press Enter key, cursor must jumps to next field, and then next, and in last it saves records, someone help me please
thanks
zami is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-31-2006, 07:44 AM Re: set focus on data entry fields
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
in ASP you can't

You have to capture the keypress with javascript and use the tabindex to got to the next field.

This code will only work in Internet Explorer
HTML Code:
<script type="text/javascript">
function ret2tab(obj) {
	var indexNo = obj.tabIndex;
	var keyCode = event.keyCode;
	var ele = document.getElementById("testform").elements[indexNo];
	if (keyCode == 13) {
		event.keyCode = 0;
		ele.focus();
		ele.select();
		}
}
</script>
Sample HTML
HTML Code:
<form name="testform" id="testform" action="" method="post">
<input type="text" name="field1" id="field1" value="Field 1" tabindex="1" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field2" id="field2" value="Field 2" tabindex="2" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field3" id="field3" value="Field 3" tabindex="3" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field4" id="field4" value="Field 4" tabindex="4" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field5" id="field5" value="Field 5" tabindex="5" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field6" id="field6" value="Field 6" tabindex="6" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field7" id="field7" value="Field 7" tabindex="7" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field8" id="field8" value="Field 8" tabindex="8" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field9" id="field9" value="Field 9" tabindex="9" onkeypress="ret2tab(this)"/><br/>
<input type="text" name="field10" id="field10" value="Field 10" tabindex="10" onkeypress="ret2tab(this)"/><br/>
 <input type="submit" name="submit1" id="submit1" value="Go" tabindex="11" /> 
</form>
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-06-2006, 06:08 AM Re: set focus on data entry fields
Novice Talker

Posts: 5
Name: zamir
Trades: 0
hi
thx i m working on it, its working now, but wehn its reaching at save button its getting hands, or stuck, well thx for your reply i will send u codes after it
thanks
zami is offline
Reply With Quote
View Public Profile
 
Old 11-06-2006, 06:35 AM Re: set focus on data entry fields
Novice Talker

Posts: 5
Name: zamir
Trades: 0
ok, its fully working now, thx for your cooperations
bye
zami is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to set focus on data entry fields
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.60279 seconds with 12 queries