Jump to content

Submit button as enter... several submits on page


marmite

Recommended Posts

Hi,

 

Sorry, I know this has been asked many times before, but searching in this forum produces 31 pages...!

 

Can anyone tell me whether I have to use javascript to allow the user to hit enter instead of clicking?

 

Do I need to have the forms in a certain order on the page at all?

 

Very happy to be redirected to another article...

 

Thanks

Link to comment
Share on other sites

function checkkey(e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
if(keycode == 13){
	submitform();
}
}

 

On your form:

 

<body onKeyPress="checkkey(event);">

 

Why don't you use '<form>' tags? The form will be post when user hit enter key.

 

Anyway, hope this help you.

Link to comment
Share on other sites

Thanks for this :)

 

I am using a form.... but hitting-enter-to-submit suddenly stopped working when I made some changes to a different page. I have no idea why ???

 

				<form action="login.php" method="POST" id="login" name="login">
				<table width="215px">
					<tr><td><img src="images/spacer.gif" width="1" height="55" alt="" /></td></tr>

					<tr>
						<td width="7px"></td>
                        	<td width="70px">Username:</td>
                        	<td width="140px"><input name="username" type="text" class="footer" id="username" size="15"></td>

                        </tr>
                        <tr>
						<td width="7px"></td>
                        	<td>Password:</td>
                        	<td><input name="password" type="password" class="footer" id="password" size="15">
                        	</td>
                        </tr>

					<tr>
						<td align="center" class="footer" colspan="3"><a href="forgottenpassword.php">Forgotten your password?</a>
						</td>
					</tr>
					<tr>
						<td>
							<img src="images/spacer.gif" width="1" height="3" alt="" />
						</td>
					</tr>
					<tr>
						<td align="center" colspan="3"><input type="image" src="images/loginbutton.gif" id='loginbutton' name='loginbutton' width="80" height="17">
						</td>
					</tr>
				</table>
				</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.