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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

oN ENTER 2

Status
Not open for further replies.

100dtl

Programmer
Aug 18, 2003
313
GB
Can anyone tell me how I submit a form on pressing enter
 
Is that right in quotes

function checkKeyPressed() {
if (event.keyCode==13){
document.forms"formReg".submit();
}
}
 
if you are using ie6 then you could use

formReg.submit()
document.forms["formReg"].submit()
document["formReg"].submit()
document.getelementbyid("formReg").submit()
 
Is there no call anywhere to this function?#

<script type=&quot;text/javascript&quot;>
<!--
window.onkeypress=checkKeyPressed;

function checkKeyPressed() {
if (event.keyCode==13){
document.getelementbyid(&quot;formReg&quot;).submit()<BR>
}
}

//-->
</script>
 
this is the call to the function

window.onkeypress=checkKeyPressed;

whcih detects when w key is pressed.

hence

window.onkeypress
 
well, I hate to tell you its still not working
 
and you have double-checked that your submit button is not outside your </form> tag right?


This should work
<input type=submit value=&quot;Enter&quot;>
</form>
 
FOMR CODE



<form method=&quot;post&quot; action=&quot;referer.asp?ty=lg&quot; ID=&quot;FormReg&quot; name=&quot;register&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; align=&quot;left&quot; cellpadding=&quot;0&quot; class=&quot;main&quot; ID=&quot;Table1&quot; >
<tr>
<td width=&quot;41%&quot; rowspan=&quot;2&quot; valign=&quot;top&quot;></td>
<td width=&quot;22%&quot; align=center><font color=&quot;#666666&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><br>

<%response.write dictLanguage.Item(Session(&quot;language&quot;)&&quot;_customerauthenticateform_7&quot;)%></strong></font></td>
<td width=&quot;37%&quot; align =right><br>
<%validate &quot;username&quot;, &quot;username&quot;%><%textbox &quot;username&quot;,&quot;&quot;, 20, &quot;textbox&quot;%> </td>
</td>
</tr>
<tr>
<td align=center><font color=&quot;#666666&quot; face=&quot;Arial, Helvetica, sans-serif&quot;><strong><%response.write dictLanguage.Item(Session(&quot;language&quot;)&&quot;_customerauthenticateform_5&quot;)%></strong></font></td>
<td align =right valign=&quot;bottom&quot;> <%validate &quot;password&quot;, &quot;required&quot;%><%textbox &quot;password&quot;,&quot;&quot;, 20, &quot;password&quot;%>
</td>
</tr>
<tr>
<td height=&quot;33&quot; valign=&quot;top&quot;>&nbsp;</td>
<td align=center>&nbsp;</td>
<td align =right valign=&quot;bottom&quot;>
<input type=&quot;Submit&quot; name=&quot;Submit&quot; value=&quot;<%response.write dictLanguage.Item(Session(&quot;language&quot;)&&quot;_customerauthenticateform_2&quot;)%>&quot; ID=&quot;Submit1&quot; onClick=&quot;if(checkForm()){document.register.submit()}&quot; >
</tr>
<tr>
<td colspan=&quot;3&quot;><br></td>
</tr>
</table>
</form>




JAVASCRIPT




<script type=&quot;text/javascript&quot;>
<!--
window.onkeypress=checkKeyPressed;

function checkKeyPressed() {
if (event.keyCode==13){
document.getelementbyid(&quot;formReg&quot;).submit()<BR>
}
}

//-->
</script>
 
Thank you everyone but i think Decojute had it


my type was button
now

<input type=&quot;Submit&quot; name=&quot;Submit&quot;

..what a bummer... It aint over though i'm afraid, the method post is not actioning my destination

<form method=&quot;post&quot; action=&quot;referer.asp?ty=lg&quot;
 
Thanks for that... i still get blank screen, its journey is to validate user, then account, it dont seem to be getting there
 
Dont call the submit button 'submit', you will just confuse the browser, avoid restricted words.


<input type=&quot;Submit&quot; name=&quot;mySubmit&quot;>
 
I've double checked aswell, since adding

script type=&quot;text/javascript&quot;>
<!--
window.onkeypress=checkKeyPressed;

function checkKeyPressed() {
if (event.keyCode==13){
document.getelementbyid(&quot;formReg&quot;).submit()<BR>
}
}

//-->
</script>

and


<input type=&quot;Submit&quot;


and


ID=&quot;FormReg&quot;


It dont wokr unless I clecik My Account


 
what does this mean?

It dont wokr unless I clecik My Account

What are you saying - that the form has been posted? if so then this post has ended - if not then be clearer - we have given you the answers, but you keep moving the goalposts - we are trying to help, but try to understand, it is at our convenience not yours, be clearer in what you want.

Simon
 
I just noticed you're using :

<form method=&quot;post&quot; action=&quot;referer.asp?ty=lg&quot; ID=&quot;FormReg&quot; name=&quot;register&quot;>

if your receiveing/processing page is looking for the url lg

Your form method should be GET
 
Sorry a bit dixlexic, typing slowyl....

After doing all that and leaving usernmae and password exposed in the address bar which i think is not a good idea its still not giving me the login page
 
ie: My Account unless i click the myaccount link
 
Perhaps you should read up a little more on asp / html / javascript.

use:

<form method=&quot;post&quot; action=&quot;referer.asp&quot; ID=&quot;FormReg&quot; name=&quot;register&quot;>
<input type=&quot;hidden&quot; name=&quot;ty&quot; value=&quot;lg&quot;>

and use request.form not querystring
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top