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

Placing a focus

I have a text field and I want that after I enter a text in this text
field, the focus goes to the button.gif. How can I do it? Any ideas?
I know that when you use an input type="submit", the focus goes
automatically to the button, but I don't want to use a button.

See please the piece of code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form name="formular" method="post" action="">
<input type="text" name="mytextfield"><p>
<input name="myButton" type="image" src="images/button.gif">
</form>
</body>
</html>

Thank you in advance. Bettina
Jul 20 '05 #1
2 5067
Hello

In IE, I would do:
<input type="text" name="mytextfield" onkeypress="if (event.keyCode==13)
this.form.myButton.focus();">
Or:
<input type="text" name="mytextfield" onkeypress="if (event.keyCode==13)
this.form.submit();"><p>

--
Elias
http://lgwm.org/
"Bettina" <bc****@tiscalinet.ch> wrote in message
news:71*************************@posting.google.co m...
I have a text field and I want that after I enter a text in this text
field, the focus goes to the button.gif. How can I do it? Any ideas?
I know that when you use an input type="submit", the focus goes
automatically to the button, but I don't want to use a button.

See please the piece of code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form name="formular" method="post" action="">
<input type="text" name="mytextfield"><p>
<input name="myButton" type="image" src="images/button.gif">
</form>
</body>
</html>

Thank you in advance. Bettina

Jul 20 '05 #2
Bettina wrote:
I have a text field and I want that after I enter a text in this text
field, the focus goes to the button.gif. How can I do it? Any ideas?
I know that when you use an input type="submit", the focus goes
automatically to the button, but I don't want to use a button.

See please the piece of code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form name="formular" method="post" action="">
<input type="text" name="mytextfield"><p>
<input name="myButton" type="image" src="images/button.gif">
</form>
</body>
</html>

Thank you in advance. Bettina


The focus doesn't "automatically" move to an <input type="submit" ...>
after entering data in <input type="text" ...>.

In some browsers, hitting the Enter key on your keyboard after entering
data in the <input type="text" ...> will submit the form. In those
browsers, hitting the Enter key on your keyboard after entering data
should submit the form just fine, even with <input type="image" ...>.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #3

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

Similar topics

4
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for...
2
by: Peter Wright | last post by:
Hi all. Hopefully this should demonstrate the problem I'm having: http://flooble.net/~pete/focus-problem-demo/ (I'm testing it in Mozilla only, but I'm not sure if it's actually a...
17
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main form has code in the AfterUpdate event which adds a...
1
by: avnrao | last post by:
Hi, I am facing a problem with control.focus (javascript). Here is the description of the issue. 1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on this, will redirect...
5
by: Tina | last post by:
How is it possible to designate a textbox so that when the .aspx page is displayed the cursor is already there so the user can just start typing instead of having to click in the textbox with the...
10
by: SHPsalm139 | last post by:
We have an Access 2K application that uses multiple forms. We currently hardcode the release number in a label on each form but this gets tedious to do each time there's a new release. I thought...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
4
by: Roger | last post by:
Hi, I am confused about the differences between this.window.focus(), window.focus(), and this.focus(). I want to use the calls in a <body onload="..."tag. What are the differences between...
3
by: Christian Blackburn | last post by:
Hi Gang, I have two text boxes on a form and if the first text box is populated, I want to place focus on the second text box at startup. However, this never seems to work. What am I doing...
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: 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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.