Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit by pressing Enter Key instead of clicking on Button

Status
Not open for further replies.

terjim

MIS
Feb 22, 2000
1
US
Do you know how to simulate a submit by pressing the Enter key as opposed to clicking on a Submit button with version 2.02 Netscape (OS/2)? Yes.. that's what my users are actually using..for now..
 
Hmmm....could try adding an argument to each of your form objects:<br>
<i>onSubmit=&quot;document.</i>form name here<i>.submit();return true;&quot;</i><br>
I'm not SURE if it'll work; but you could @ least give it a try :) <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= shared.freeservers.com/searchmaster.html>SearchMaster Interface...11-in-1</a><br>Wanting to learn Assembler; please e-mail me any tutorials or links for it that are useful to you :)
 
You're using very old technology if you're using Netscape V2. Time to upgrade.<br>
<br>
I'm not sure what version of Javascript Netscape V2.02 supports, but presuming Javascript 1.1, you can catch the enter key by trapping keydown events at the document level.<br>
<br>
Assuming that you've already checked to make sure it's Netscape:<br>
<br>
&lt;head&gt;<br>
&lt;script language=javascript&gt;<br>
function trapKeys(){<br>
document.captureEvents(Event.KEYPRESS);<br>
document.onkeypress=checkKey;<br>
return true;<br>
}<br>
<br>
function checkKey(EventObject) {<br>
var iKeyVal = eval(EventObject.which);<br>
<br>
if (iKeyVal==13) <br>
document.forms[0].submit();<br>
return true;<br>
}<br>
&lt;/script&gt;<br>
&lt;/head&gt;<br>
&lt;body onload=&quot;trapKeys()&quot;&gt;<br>
<br>
FORM CODE GOES HERE<br>
<br>
&lt;/body&gt;<br>
<br>
<br>
Note that this is from memory and there may be typos, but it should send you in the right direction.<br>
<br>
regards,<br>
-nick bulka<br>

 
Navigator 2.x supports JavaScript 1.0.&nbsp;&nbsp;JavaScript 1.0 does not support keyboard events so you cannot use that. The keyboard events were introduced in JS 1.2.&nbsp;&nbsp;Javascript 1.1 was introduced in NS 3.x, JS 1.2 with NS 4.0 to 4.05, JS 1.3 from NS 4.06 to present, with JS 1.4 expected in NS 5.0 [6.0?].&nbsp;&nbsp;So I would recommend an upgrade to NS 4.06 or higher.&nbsp;&nbsp;But.....<br><br>JavaScript 1.0 does support onBlur, onFocus, onChange and onSubmit.&nbsp;&nbsp;Assuming the 'Tab' key actually tabs to the next field, you might be able to use the onBlur event in your text field to fire a submit with the 'Tab' key.&nbsp;&nbsp;But I don't think you're going to do it with the 'Enter' key.<br><br>The ONLY other way I can think of off the top of my head is to read the raw keyboard code (not the ASCII code) but you would need to do that with another language--more complex than you want to get.&nbsp;&nbsp;Not to mention, I don't know where to find a table of raw keyboard codes for IBM compatibles.
 
Actually, Netscape 2.02 for OS/2 is not the same as that version for Windows.&nbsp;&nbsp;It has JavaScript and all the other features of the v3.x Netscape for Windows.&nbsp;&nbsp;But Netscape 4.61 is available for OS/2.&nbsp;&nbsp;Why not use it?<br><br>DonP<br>(another OS/2 user)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top