473,386 Members | 1,842 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,386 software developers and data experts.

trying to work with onfocus

Here is the layout of my form from left to right, from top to down.

- buttonA, buttonB, buttonC
- textbox, textbox, textbox
- buttonXXX

After the user types in the textboxes and press enter (with the cursor still
in one of the textboxes), buttonXXX should be pressed by default.(the user
is too lazy to take the cursor over to buttonXXX and click).

The problem is the top/left most button (button A) gets pressed which annoys
them to death. So I tried to do this.

In the bottonA's onfocus event handle-
document.forms[0].elements['buttonXXX'].focus() .

Result: ButtonXXX receives focus alright, but the code for buttonA still
executes! Any help would be greatly appreciated.

Jul 23 '05 #1
1 1289
Check if buttonA is a standard button (<input type="button" ...>)
and if butonXXX is a default/submit button (<input type="submit"
....>).
The code to be executed on clicking "buttonXXX" should be in a
function, suck as buttonXXX_click. See if the "action" attribute for
the "form" element is "buttonXXX_click()" (<form
action="buttonXXX_click()" ...>).

Hope this help,
Nuno Silva (aka NJSG)

=== - ===
My english isn't very good, because it isn't my first language. If you
found any mistake (or have problems understanding the post), tell me.
=== - ===
I have a 33.3 kbps Internet Dial-Up Connection.
Please wait by my replies with patience.

David escreveu:
Here is the layout of my form from left to right, from top to down.

- buttonA, buttonB, buttonC
- textbox, textbox, textbox
- buttonXXX

After the user types in the textboxes and press enter (with the cursor still
in one of the textboxes), buttonXXX should be pressed by default.(the user
is too lazy to take the cursor over to buttonXXX and click).

The problem is the top/left most button (button A) gets pressed which annoys
them to death. So I tried to do this.

In the bottonA's onfocus event handle-
document.forms[0].elements['buttonXXX'].focus() .

Result: ButtonXXX receives focus alright, but the code for buttonA still
executes! Any help would be greatly appreciated.


Jul 23 '05 #2

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

Similar topics

9
by: Dwalker | last post by:
I just want to enter today's date in a text input box with the format mm/dd/yyyy when it receives focus. I've been playing around with this but just can't seem to get it to work. Any help would...
2
by: Mike Berger | last post by:
So, I'm fairly new to this and my code is as follows... <script language="JavaScript> var oldValue function focusElement(theElement) { oldValue = theElement.value; return; } </script>
1
by: Rich Morey | last post by:
Hello, I have created a form and assigned each of the form elements to a class in a style sheet. I would like to know if it is possible to add 'OnFocus' and 'OnBlur' events to the style sheet...
2
by: Paresh Shah | last post by:
Hi Friends... I have an query on how to capture onFocus event for all the input controls without writing onFocus event in the <input> tag. say my html form has 3 or 4 or 5 input text boxes,...
1
by: Tzachi | last post by:
Hello all, I have a function that dynamically adds rows and columns to the page. Everything works well except onfocus // onblur attributes. For some reason, when entering the input box it...
6
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the...
12
by: effendi | last post by:
I wrote the following function and tested it in MSIE, Firefox and Mac Safari, Works in all but the Safari. What can I do to rectify this? function processBackground(){ for (n=1;n<11;n++) { ...
8
by: jd2007 | last post by:
Why the Ajax code below in ajax.js is causing my form not to work ? ajax.js: var a=0; var b=0; var c=0; var d=0; var e=0; var f=0;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.