|
|
|
|
![]() ![]() |
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 |
|
|
|
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. |
|
|
|
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) 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). |
|
|
|
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. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 10th October 2008 - 06:45 PM |