473,406 Members | 2,378 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,406 software developers and data experts.

Automated Change of focus

Hi guys

The code below will be used to fill in a crossword grid.
When a user types a letter, focus is changed to next cell in the grid.

My code doesn't work and I would be grateful if you could help me ...

The script is :

function changefocus(theevent,thetarget)
{
if (theevent > 64 && theevent < 91){cross1.thetarget.focus();}
}
Part of the HTML is :
<form name="cross1">
<input type="text" name="A1" onKeyUp="changefocus(event.keyCode,'A2');">
<input type="text" name="A2" onKeyUp="changefocus(event.keyCode,'A3');">
<input type="text" name="A3" onKeyUp="changefocus(event.keyCode,'A1');">
</form>

Thank you,
Aug 23 '05 #1
3 3124
Lee
bunch92 said:

Hi guys

The code below will be used to fill in a crossword grid.
When a user types a letter, focus is changed to next cell in the grid.

My code doesn't work and I would be grateful if you could help me ...

The script is :

function changefocus(theevent,thetarget)
{
if (theevent > 64 && theevent < 91){cross1.thetarget.focus();}
}
Part of the HTML is :
<form name="cross1">
<input type="text" name="A1" onKeyUp="changefocus(event.keyCode,'A2');">
<input type="text" name="A2" onKeyUp="changefocus(event.keyCode,'A3');">
<input type="text" name="A3" onKeyUp="changefocus(event.keyCode,'A1');">
</form>


If you don't mind that it won't work in Netscape or Firefox,
it looks like all you need to do is change:
cross1.thetarget.focus()
to:
cross1.elements[thetarget].focus()

If you want it to work more generally, you need to change
that to:
document.cross1.elements[thetarget].focus()
and you need to change:
event.keyCode
to:
event.keyCode|event.charCode

Aug 23 '05 #2

"Lee" <RE**************@cox.net> wrote in message
news:de*********@drn.newsguy.com...
If you want it to work more generally, you need to change
that to:
document.cross1.elements[thetarget].focus()
and you need to change:
event.keyCode
to:
event.keyCode|event.charCode


Thank you, I will try that tomorrow and let you know if I succeeded.
Aug 23 '05 #3
Lee <RE**************@cox.net> wrote in news:de*********@drn.newsguy.com:
If you want it to work more generally, you need to change
that to:
document.cross1.elements[thetarget].focus()
and you need to change:
event.keyCode
to:
event.keyCode|event.charCode

It works perfectly.
Thank you very much Lee
Aug 24 '05 #4

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

Similar topics

8
by: Max M | last post by:
Yesterday there was an article on Slashdot: http://books.slashdot.org/article.pl?sid=03/09/04/1415210&mode=flat&tid=108&tid=126&tid=156 It is about automatic code generation. I got interrested...
2
by: Konstantin Zakharenko | last post by:
Hello, Our QA team have running a lot of test scripts (for automated regression testing), they run them on the different databases (Oracle/MS SQL). Several of those tests are dependent on the...
0
by: Wayne Wengert | last post by:
I have a form on which I change background colors when textbox get focus and I reset the background color when it loses focus. This works fine except when I change the focus via code. If I validate...
1
by: swestenra | last post by:
I am trying to build a screen scraper. But not just a plain screen scraper, it must also automate the entry of data. Background: We have a new intranet system that goes in to production soon. ...
4
by: Jon Slaughter | last post by:
I've created some custom controls and forms that allow the feature to temporarily transfer focus to a control that has been entered by the mouse. Everything seems to work fine but the problem I...
7
by: helraizer1 | last post by:
Hey, I have a table called TblStock with 10 columns but 3 which need the focus here. These three columns are 'Stock Level', 'Re-order Level' and 'Re-order Quantity'. The Stock level fields...
3
by: viral123 | last post by:
Hi all, does any one know how to get the functionality of get focus and lost focus using ASP.Net like VB.Net I want to change the textbox back ground color when it has the focus. I used...
11
by: cmdolcet69 | last post by:
I have the code below that will evaluate a string of characters. If its less then 12 long it will trigger a message box if its equal it will save the information and close the form. I have this...
10
by: engteng | last post by:
When textbox properties enable = False the font in the textbox become gray color. How do I change the gray color to black color ? Regards, Tee
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.