SitePoint Sponsor |
|
User Tag List
Results 1 to 14 of 14
Thread: submit on enter ?
-
Sep 3, 2003, 11:49 #1
- Join Date
- Nov 2001
- Location
- Colorado
- Posts
- 2,085
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
submit on enter ?
in a typical form when you hit the enter key it will submit the data, however I am not using a submit button but rather a regular button the calls this funtion:
Code:function submitDB(){ var itemnum = document.formhandheld.itemnum.value; var readSource = 0; var readType = 0; window.location.href = "PocketPCDetails.asp?ScanCheck=1&itemnum=" + itemnum + "&readSource=" + readSource + "&readType=" + readType; }
WordPress Plugins: Comment Info Tip
My Blogs: What a Savage | Search-This
Tools: Search Engine Decoder | PageRank Decoder
Podcast: Rand Fishkin | SitePoint Founders
-
Sep 3, 2003, 12:36 #2
- Join Date
- Nov 2001
- Location
- The Central Plains
- Posts
- 3,304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
add an onSubmit(submitDB); to the button?
-
Sep 3, 2003, 12:37 #3
- Join Date
- Nov 2001
- Location
- The Central Plains
- Posts
- 3,304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
actually, it's this (i think) in the action portion of the form:
onSubmit="submitDB();"
-
Sep 3, 2003, 12:54 #4
- Join Date
- Sep 2000
- Location
- Halmstad, Sweden
- Posts
- 7,400
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Did this work? I'm really interested in this.
Mattias Johansson
Short, Swedish, Web Developer
Buttons and Dog Tags with your custom design:
FatStatement.com
-
Sep 3, 2003, 12:56 #5
- Join Date
- Nov 2001
- Location
- Colorado
- Posts
- 2,085
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hmmm, not sure I get that, like action="submitDB()" ??
and then do I change the button to be a submit buttonWordPress Plugins: Comment Info Tip
My Blogs: What a Savage | Search-This
Tools: Search Engine Decoder | PageRank Decoder
Podcast: Rand Fishkin | SitePoint Founders
-
Sep 3, 2003, 13:00 #6
- Join Date
- Nov 2001
- Location
- Colorado
- Posts
- 2,085
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I cant seem to get it
WordPress Plugins: Comment Info Tip
My Blogs: What a Savage | Search-This
Tools: Search Engine Decoder | PageRank Decoder
Podcast: Rand Fishkin | SitePoint Founders
-
Sep 3, 2003, 13:31 #7
- Join Date
- Nov 2001
- Location
- The Central Plains
- Posts
- 3,304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
can we see the relevant code?
-
Sep 3, 2003, 13:36 #8
- Join Date
- Nov 2001
- Location
- Colorado
- Posts
- 2,085
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
here's what I have:
Code:function submitDB(){ var itemnum = document.formhandheld.itemnum.value; var readSource = 0; var readType = 0; window.location.href = "PocketPCDetails.asp?ScanCheck=1&itemnum=" + itemnum + "&readSource=" + readSource + "&readType=" + readType; }
Code:<form method="get" name="formhandheld">
Code:<input type="button" name="Details" value=" Details " onClick="submitDB()">
WordPress Plugins: Comment Info Tip
My Blogs: What a Savage | Search-This
Tools: Search Engine Decoder | PageRank Decoder
Podcast: Rand Fishkin | SitePoint Founders
-
Sep 3, 2003, 14:00 #9
- Join Date
- Nov 2001
- Location
- The Central Plains
- Posts
- 3,304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
the enter key probably has to do with it not being a submit button(?). hmmmmm... any reason why it can't be a submit button?
-
Sep 3, 2003, 14:07 #10
- Join Date
- Oct 1999
- Location
- Dublin, Ireland
- Posts
- 1,125
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I figured this exact problem out in my previous job on a project. I can't remember what code I used, but I remember that I had to get the Javascript to recognise that the return hit had been pressed, which is number 13 on the keycode list (if I remember correctly).
These links might help somewhat:
http://www.allasp.net/enterkey.aspx
http://www.cs.tut.fi/~jkorpela/forms/enter.html
-
Sep 3, 2003, 15:28 #11
- Join Date
- Nov 2001
- Location
- Colorado
- Posts
- 2,085
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I GOT IT...
strange though had to remove the form tag.WordPress Plugins: Comment Info Tip
My Blogs: What a Savage | Search-This
Tools: Search Engine Decoder | PageRank Decoder
Podcast: Rand Fishkin | SitePoint Founders
-
Sep 3, 2003, 16:59 #12
- Join Date
- Nov 2001
- Location
- The Central Plains
- Posts
- 3,304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
woo hoo!
-
Sep 4, 2003, 01:19 #13
- Join Date
- Dec 2001
- Location
- Gouda, The Netherlands
- Posts
- 64
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Actually, removing the form-tag is not the correct way, as this introduces an incompatibility. Some browsers will even choke on a submit button that is not found within a form.
The correct way to handle this is to place an onsubmit event handler in the form tag:
Code:<form ... onsubmit="return submitHandler()">
Kiffin
Your average future-famous kind of guy...
-
Sep 4, 2003, 08:11 #14
- Join Date
- Nov 2001
- Location
- Colorado
- Posts
- 2,085
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok, perhaps then you can help me, since as soon as I add the form back it wont work....
relevent code is in red...
Code:<%@LANGUAGE="JAVASCRIPT"%> <html> <head> <title>Hand Held Item Entry</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript"> function enterkey(eEvent) { if (eEvent.keyCode == 13){ submitDB(); } return true; } function submitDB(){ var itemnum = document.all.itemnumHolder.value; var readSource = 0; var readType = 0; window.location.href = "PocketPCDetails.asp?ScanCheck=1&itemnum=" + itemnum + "&readSource=" + readSource + "&readType=" + readType; } function logOff(){ window.location.href="pocketLogin.asp"; } </script> </head> <body bottommargin="0" topmargin="0" rightmargin="0" leftmargin="0"> <form method="get" name="formhandheld" onsubmit="return enterkey()"> <table width="225" border="0" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#e3e3e3" valign="top"> <table width="100%" height="320" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#e3e3e3" height="*" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" align="center" bgcolor="#00CC33"> <font size='-1' face='verdana,arial'>Hand Held Item Maintenance</font> </td> </tr> <tr> <td> </td><td> </td> </tr> <tr> <td colspan="2" align="center"><font face='verdana,arial'>Scan Item or Key Enter Item</font></td> </tr> <tr> <td align="center" colspan="2"><input name="itemnumHolder" type="text" onkeypress="return enterkey(event)" size="30" maxlength="13" ></td> </tr> <tr> <td align="center" colspan="2"> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#999999" height="28"><div align="center"> <input name="Log_Off" type="button" value=" Log Off " onClick="logOff()"><br /> <input type="button" name="Details" value=" Details " onClick="submitDB()"> <input type="reset" name="Cancel" value=" Cancel "> <input type="button" name="Help" value=" Help " onClick="window.location.href="pocketScanItem_Help.asp""> </div></td> </tr> </table></td> </tr> </table> </form> </body> </html>
WordPress Plugins: Comment Info Tip
My Blogs: What a Savage | Search-This
Tools: Search Engine Decoder | PageRank Decoder
Podcast: Rand Fishkin | SitePoint Founders
Bookmarks