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
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
 
When You Register, These Ads Go Away!
Old 10-31-2006, 07:44 AM Re: set focus on data entry fields
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,830
Location: Blackpool. UK
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!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
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
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
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

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

vB 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.12216 seconds with 12 queries