473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Autotab on specifig keycode

I need to copy a lot of information to a lot of textfields from a text
file. It is possible to just put all the information on on long line
seperated by e.g. '*' and whenever a '*' occurs the tab-key is
automatically "pressed" so the cursor jumps to the next textfield?

Thanks

regards Frank

Oct 3 '06 #1
1 1261
On 2006-10-03 10:41:12 +0200, "frankja" <fr************@gmail.comsaid:
I need to copy a lot of information to a lot of textfields from a text
file. It is possible to just put all the information on on long line
seperated by e.g. '*' and whenever a '*' occurs the tab-key is
automatically "pressed" so the cursor jumps to the next textfield?
Emulating a tab keypress seems a lot of trouble. You can use JavaScript
to split a string into substrings and copy each into a corresponding
form input, without using any UI trick.

Say your form inputs are all referenced in an array (use push() to add
each appropriate input element to the array so there won't be gaps in
the array indexes, that would make the rest of the code more
complicated than it needs to be).

function spreadStringIntoInputs(str, inputs)
{
var parts = str.split("*")
var s, i=0

if(parts.length inputs.length)
alert("uh oh, there aren't enough inputs to hold all the substrings.")
else
while(s=parts[i])
inputs[i].value=parts[i]
}

Now, that code is not very flexible. You should improve the way it
handles overflowing substrings (ignore them or dump them all into the
last input ?).
Either way, using some Array methods, you should be able to achieve
that by altering the 'parts' array and then proceed with the while()
loop, so you must remove the else statement: if(more strings than
inputs) make the array shorter somehow; whatever happened before, run
the loop.

--
David Junger

Oct 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matthias Knöchlein | last post by:
hi !! I have the following problem : Is there a function or a constant value to check if a keyCode is a key kile "Shift", "Alt" or "F1". I would like not to use this way : if( ...
1
by: Perttu Pulkkinen | last post by:
I have different functions that receive window.event as parameter. Functions are used like this: <input type="text" id="x" onkeypress="return onKeyCurrencyCheck(ev, 'x')" onblur...
6
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function...
4
by: Thomas Christensen | last post by:
I'm trying to figure out what key the user pressed using a Danish keyboard layout. charCodeAt returns the correct number, but event.keyCode returns a wrong number, when using one of the keys that...
3
by: Pugi! | last post by:
I got this (piece of) script from 'DHTML Utopia - Modern Webdesign - Using Javascript & DOM'. function aKeyWasPressed(e) { if (window.event) { var key = window.event.keyCode; } else { var key...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
4
by: Nathan Sokalski | last post by:
I am writing a piece of code for an ASP.NET function that generates an onKeyPress JavaScript eventhandler that uses the event.keyCode / event.which properties. I have two situations that I would...
2
by: keithtracypierce | last post by:
1)Access2003, beating my head against the wall, every other iteration is "can't find macro Upshift" followed by carefully verifying that no blank properties have been entered. Making NO changes at...
3
by: Paul Gorodyansky | last post by:
Hi, I have function that works via onkeypressed - for example, what to catch when a user presses a punctuation symbol such as '.' So I check keyCode for that - works just fine in Opera 8,...
2
dlite922
by: dlite922 | last post by:
got the following code that works great in IE, i have need an exception to these rules. Why to Tab? Users come from old Apps (data entry people) and want to use the enter key to move through...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.