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

Add option to press Enter key (for Dummies)

I have a form where user enters a password text, then has to click the Submit Password button. How do I add the option to press Enter key to call the same function 'goForit'?

I read similar posts/replies, but I don't know enough to make it work for me. I got this form and script from a free sript site. Trying to learn...thahks in advance for any help.

here is the code:
[html]
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

function goForit() {
var location;
var password;
password=this.document.testform.inputbox.value
location=password + ".asp"
fetch(location)
theKeeper=window.close()
}
function fetch(location) {
var root;
if (opener.closed) {
root=window.open('','theKeepersGopher','toolbar=ye s,location=yes,status=yes,menubar=yes,scrollbars=y es,resizable=yes,copyhistory=no');
root.location.href = location;
} else {
opener.location.href = location;
}
}
// End -->
</SCRIPT>
</head>
<body onLoad="top.window.focus()" BACKGROUND="images/gatekeeper_managers1.jpg">

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR>
<TD ROWSPAN=2 WIDTH=200px><img src="../images/clear_1px.gif" width="200px" height="1">
<TD WIDTH=50% ALIGN=CENTER VALIGN=MIDDLE class="maintext" style="color: #ffffff;">
<p>&nbsp;</p>
<p>Please enter your Password. If you do not have one, contact your Manager for
Assistance.
<BR>
</p>
<TR>
<TD WIDTH=50% ALIGN=CENTER VALIGN=BOTTOM>
<p>&nbsp</p>
<CENTER>
<FORM NAME="testform">
<INPUT TYPE="text" NAME="inputbox" VALUE="" size=20>
<INPUT TYPE="button" NAME="button" Value="Submit Password" onClick="goForit(this.form)">
</FORM>
</CENTER>
</TABLE>
</body>
</html>
[/html]
<!-- Script Size: 1.71 KB -->
Nov 21 '08 #1
2 3432
RamananKalirajan
608 512MB
This example may help you.


[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="Ramanan">
<META NAME="Keywords" CONTENT="demo Form">
<META NAME="Description" CONTENT="Form Submit">
<script type="text/javascript">
function doValidate()
{
alert("Inside Validate Function");
return false;
}
</script>
</HEAD>

<BODY>
<form action="demoTrial.html" method="post" onsubmit="return doValidate()">
<table align="center">
<tr><td>User Name </td><td><input type="text" id="myText" name="myText" /></td></tr>
<tr><td>Password </td><td><input type="text" id="myText1" name="myText1" /></td></tr>
</table>
<input type="submit" value="doSubmit">
</form>
</BODY>
</HTML>[/HTML]

Instead of using button to submit the form, write a submit input type and trigger the submit function in the form tag. That would do the work what you are looking for.

Regards
Ramanan Kalirajan
Nov 21 '08 #2
Ramanan,
Thank you sir. Got it to work.

Darrell
Nov 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: JCO | last post by:
How's come when I press the enter key, I can't get it to execute the correct password. It seems that I'm forced to press the button. I want to be able to do both. How is this done?
4
by: penny336 | last post by:
hi here is my original// it can convert to upper case or lower case but require user press "enter" how to implement a without "press enter" version e.g. if input 'a' --> at commad prompt will show...
6
by: Johan Svedberg | last post by:
Hi! I read somewhere that it is impossible to write a program in ANSI-C which only reads one char from the keyboard without having to press Enter (i.e. -questions). Is this true? -- Johan...
5
by: junk mail | last post by:
My friend is trying to code a small c program where he wants to force the user to press enter and only enter to continue. Currently he is using getchar() with a loop but you can type any number...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
16
by: TetoPR | last post by:
Hi, I'm trying to set up an Option Box in a form to feed a Parameter Query to be used as a filter. That field I want to filter is a Text field and has two posible values: "A" and "B". So my Option...
2
by: Greoasy | last post by:
I have a registration page with no of text boxes and 3 buttons for insert update and delete. and a logout button on the top of the page. If i place my control in an of the text box and press enter...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.