Placing a focus

B

Bettina

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
 
L

lallous

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>
 
G

Grant Wagner

Bettina said:
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 <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_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-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,219
Latest member
Geraldine7

Latest Threads

Top