Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Submit Button
kvarnerexpress
post Aug 30 2005, 09:39 PM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



I have a form on my page. I do not have a submit button, but when I hit enter on my text field, it is like I am clicking on a submit button. My page refreshes to the original state, and my values are reset.

I found this out because I made a submit button and tried it.

Is there a way to get around this? I am trying to use a javascript that captures the key strokes. That works, but then the submit like event still fires after my code runs, nullifying any changes my code has made.

html4strict Code:

CODE
1.
     <form name="FormPictureInfo">
  2.
         <table cellpadding="0" cellspacing="4" border="0" align="center">
  3.
             <tr>
  4.
                 <td align="center"><input type="text" name="ProductCode" size="22" maxlength="256" value="default" onFocus="clearBox(this);" /></td>
  5.
                 <td align="center"><div class="infotitle">Product:</div></td>
  6.
                 <td align="center"><div class="infotitle">Comments:</div></td>
  7.
                 <!--<td align="center"><div class="infotitle">Picture Date:</div></td>-->
  8.
                 <td valign="top" align="center"><div class="Descriptor" id="BagSize">Bag Size</div></td>
  9.
             </tr>
 10.
             <tr>
 11.
                 <td><table cellpadding="2" cellspacing="6" border="0">
 12.
                     <tr>
 13.
                         <td valign="top" align="center"><input type="button" value="Display Picture" onclick="FillDataShowPic(document.FormPictureInfo.ProductCode.value);"/></td>
 14.
                     </tr>
 15.
                     <tr>
 16.
                         <td valign="top" align="center"><input name="ZoomButton" type="button" value="ZOOM" onclick="Zoom(document.getElementById('ProductCodeDisplay').innerHTML);"/></td>
 17.
                     </tr>
 18.
                 </table></td>
 19.
                 <td valign="top"><table cellpadding="0" cellspacing="2" border="0">
 20.
                     <tr>
 21.
                         <td align="center"><div class="Descriptor" id="ProductName">Product Name</div></td>
 22.
                     </tr>
 23.
                     <tr>
 24.
                         <td align="center"><div class="Descriptor" id="ProductCodeDisplay">Product Code Display</div></td>
 25.
                     </tr>
 26.
                     <tr>
 27.
                         <td valign="top" align="center"><div class="Descriptor" id="PictureDate">Picture Date</div></td>
 28.
                     </tr>
 29.
                 </table></td>
 30.
                 <td valign="top" align="center"><div class="DescriptorArea" id="ProductComments">Product Comments</div></td>
 31.
                 <td><table cellpadding="0" cellspacing="2" border="0">
 32.
                     <tr>
 33.
                         <td align="center"><div class="Descriptor" id="SetPoint">Set Point</div></td>
 34.
                     </tr>
 35.
                     <tr>
 36.
                         <td valign="top" align="center"><div class="Descriptor" id="Density">Density</div></td>
 37.
                     </tr>
 38.
                     <tr>
 39.
                         <td valign="top" align="center"><input type="button" value="Close" onclick="self.close();"/></td>
 40.
                     </tr>
 41.
                 </table></td>
 42.
             </tr>
 43.
         </table>
 44.
         </form>



Thanks,kvarnerexpress
Go to the top of the page
 
+Quote Post
cse-icons
post Aug 31 2005, 07:06 AM
Post #2


Super Member
*********

Group: Members
Posts: 351
Joined: 19-October 04
From: India
Member No.: 1,824



If I understand properly, u do not wish the form to submit on "Enter".
To prevent this you can have a

CODE

<form action="" onSubmit="func()">


The onsubmit event would fire on pressing enter, which would call the javascript function "func()". In this function u can do the processing and submit if u want or else just leave it.

Cheers.
Go to the top of the page
 
+Quote Post
Lozbo
post Sep 6 2005, 10:18 PM
Post #3


Super Member
*********

Group: Members
Posts: 282
Joined: 1-September 05
From: Wanatos
Member No.: 11,382



QUOTE(cse-icons @ Aug 31 2005, 01:06 AM)
CODE

<form action="" onSubmit="func()">

*


I think you could also put a submit button with the atribute

CODE

... <input type="submit" onClick="func()">...


which is suposed to do exacly the same (even if you omit the 'onSubmit' atribute on the form tag).
Go to the top of the page
 
+Quote Post
reatum
post Oct 4 2005, 12:14 AM
Post #4


Member [Level 1]
****

Group: Members
Posts: 63
Joined: 3-October 05
Member No.: 12,515



all you need to do to keep the form from submitting on enter is
CODE

<form name="whatever" onSubmit="return false;">


then use javascript to tell your form what to do with some sort of listener or an onclick function on a submit button like lozbo said.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Delphi Tutorial - Change Your Start Button Caption(4)
  2. Psp Square Button Problem(12)
  3. Linking A Url To A Button(4)
  4. Button To Print Current Web Page(14)
  5. Radio Button(4)
  6. How To Create Java Button Or Frame(14)
  7. Refresh Page After Back Button Hit(11)
  8. Multiple Drop Down Menus W/ Submit Button(6)
  9. Preventing A Form To Submit If A Field Is Empty?(7)
  10. I Need A Free Way To Submit My Website To The Search Engines(6)
  11. Wireless Computer Remote Power Button - Using A Doorbell(3)
  12. Submit Multiple Forms At Once(5)
  13. Button Animation With Rollover State That Stays When User Clicks A Button(0)
  14. A "save As Draft" Button(13)
  15. Giving A Flash Button A Link(3)
  1. Getting Information From Submit Button(1)
  2. Stop Double Post/submit(10)
  3. Rounded Corners & Go Button(6)
  4. System Tray And Start Button Problem(1)
  5. Submit Your Site To Google(14)
  6. Download Files Off Esnips.com(0)
  7. Delaying The Time Until A Flash Button Can Be Pressed(3)
  8. List Of Free Directories To Submit Your Websites(7)
  9. Frontpage Problem(0)
  10. Cd Drive Eject Button Problem(3)
  11. How To Make Image Buttons Act As Submit Button(8)
  12. Destination Address For "submit" Button(5)
  13. The Proper Method To Submit Tickets At Xistosupport(4)


 



- Lo-Fi Version Time is now: 10th October 2008 - 06:45 PM