By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,970 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,970 IT Pros & Developers. It's quick & easy.

Placing a focus

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.