473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why is it that the onsubmit event doesn't work ?

1
I noticed that the onclick event works but the onsubmit doesn't why is it ?

Below is the code of my form. Please help me resolve this issue.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Form</title>
  4. <SCRIPT LANGUAGE="Javascript">
  5. <!-- Displays the name in the second textbox
  6. function displayName()
  7. {
  8.     var d1=document.personalForm.firstName.value;
  9.     document.personalForm.fname.value=d1;    
  10.  
  11. }
  12. Ends Here-->
  13. </SCRIPT>
  14. </head>
  15. <body onLoad="displaymessage()">
  16. <table border="0">
  17. <Form name="personalForm" method="post">
  18. <tr>
  19. <td width="100px"><label>Name :</label></td><td><input type="text" name="firstName"></td>
  20. </tr>
  21. <tr>
  22. <td width="100px" height="26"><label>Password :</label></td><td><input type="Password" name="pwd"></td>
  23. </tr>
  24. <td width="300px"><label>Date of Birth :</label></td><td><select name="day">            
  25. <SCRIPT LANGUAGE="Javascript">
  26. <!--Hide
  27. var d;
  28.  
  29. for(d=1;d<=31;d++)
  30. {
  31.     document.write("<option value=\"d\">",d,"</option>");
  32.  
  33. }
  34. -->
  35. </SCRIPT>                                       
  36. </select> 
  37. <select name="month"><option value="January">Jan</option><option value="February">Feb</option><option value="March">Mar</option><option value="April">Apr</option><option value="May">May</option><option value="June">Jun</option>
  38. <option value="July">Jul</option><option value="August">Aug</option><option value="September">Sep</option><option value="October">Oct</option><option value="November">Nov</option><option value="December">Dec</option></select>
  39. <select name="year">
  40. <SCRIPT LANGUAGE="Javascript">
  41. <!--Hide
  42. var y;
  43.  
  44. for(y=1900;y<=1996;y++)
  45. {
  46.     document.write("<option value=\"y\">",y,"</option>");
  47.  
  48. }
  49. -->
  50. </SCRIPT>                                       
  51. </select> 
  52. </td>
  53. <td height="37"></tr>
  54. <tr>
  55. <td><label>Sex :</label></td><td><input type="radio" name="sex" value="male" checked="checked"><label>Male</label>
  56. <input type="radio" name="sex" value="female"><label>Female</label>
  57. </td>
  58. </tr>
  59. <tr><td><label>Your name is:</label></td><td><input type="text" name="fname"></td></tr>
  60. </form>
  61. <tr><td colspan="2"><center>
  62.   <input type="Submit" value="Submit" onsubmit="displayName()"/>
  63. </center></td>
  64. </table>
  65. </body>
  66. </html><html>
  67. <head>
  68. <title>Form</title>
  69. <SCRIPT LANGUAGE="Javascript">
  70. <!-- Displays the name in the second textbox
  71. function displayName()
  72. {
  73.     var d1=document.personalForm.firstName.value;
  74.     document.personalForm.fname.value=d1;    
  75.  
  76. }
  77. Ends Here-->
  78. </SCRIPT>
  79. </head>
  80. <body onLoad="displaymessage()">
  81. <table border="0">
  82. <Form name="personalForm" method="post">
  83. <tr>
  84. <td width="100px"><label>Name :</label></td><td><input type="text" name="firstName"></td>
  85. </tr>
  86. <tr>
  87. <td width="100px" height="26"><label>Password :</label></td><td><input type="Password" name="pwd"></td>
  88. </tr>
  89. <td width="300px"><label>Date of Birth :</label></td><td><select name="day">            
  90. <SCRIPT LANGUAGE="Javascript">
  91. <!--Hide
  92. var d;
  93.  
  94. for(d=1;d<=31;d++)
  95. {
  96.     document.write("<option value=\"d\">",d,"</option>");
  97.  
  98. }
  99. -->
  100. </SCRIPT>                                       
  101. </select> 
  102. <select name="month"><option value="January">Jan</option><option value="February">Feb</option><option value="March">Mar</option><option value="April">Apr</option><option value="May">May</option><option value="June">Jun</option>
  103. <option value="July">Jul</option><option value="August">Aug</option><option value="September">Sep</option><option value="October">Oct</option><option value="November">Nov</option><option value="December">Dec</option></select>
  104. <select name="year">
  105. <SCRIPT LANGUAGE="Javascript">
  106. <!--Hide
  107. var y;
  108.  
  109. for(y=1900;y<=1996;y++)
  110. {
  111.     document.write("<option value=\"y\">",y,"</option>");
  112.  
  113. }
  114. -->
  115. </SCRIPT>                                       
  116. </select> 
  117. </td>
  118. <td height="37"></tr>
  119. <tr>
  120. <td><label>Sex :</label></td><td><input type="radio" name="sex" value="male" checked="checked"><label>Male</label>
  121. <input type="radio" name="sex" value="female"><label>Female</label>
  122. </td>
  123. </tr>
  124. <tr><td><label>Your name is:</label></td><td><input type="text" name="fname"></td></tr>
  125. </form>
  126. <tr><td colspan="2"><center>
  127.   <input type="Submit" value="Submit" onsubmit="displayName()"/>
  128. </center></td>
  129. </table>
  130. </body>
  131. </html>
Jul 29 '09 #1
2 3653
gits
5,390 Expert Mod 4TB
i guess that it behaves like that because the submit-buttons are outside of the form-tags ...
Jul 31 '09 #2
Canabeez
126 100+
And I think the onSubmit="" should be under <FORM>, not under <INPUT>.
Aug 2 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: George Hester | last post by:
I have a page that loads an applet. It's a cube that is used as a navigation menu. This issue actually happens in both Microsoft Internet Explorer and Netscape. All versions that I know of. And...
1
by: Yuriy | last post by:
I added controls dynamicaly to placeholder control and declared event to control. When I try execute event it doesn't work on server side. Protected WithEvents myButton1 As...
3
by: Jump Off! | last post by:
Hi, I work with ASP.NET v2 (visual web dev 2005 express) and, when i want to use the CheckedChanged Event of a checkbox, it doesn't work. I want to enable a button when checkbox is checked,...
5
by: Andy Fish | last post by:
Hi, I have an asp.net web application which uses a pop-up form that works a bit like a dialog box. when the user clicks "OK" it does a postback (basically a form post if you don't know .net) to...
3
by: ajfish | last post by:
Hi, I have a web form with smart navigation turned on. the html has an onload event which calls a javascript function and the contents of this function are dynamically generated on the server...
2
by: Chu | last post by:
Thanks everyone for taking a moment to read this. I've got a page where I use a LinkButton and I wire up a dynamic event to the button. When the user clicks the button, the event is fired as...
10
by: nasir872 | last post by:
I am having trouble in calling tab event using my own function. i call tab event using event.keyCode = 9; but firefox gives this error "Error: event is not defined". What to do? plz help
1
by: analfabete | last post by:
Hello everybody! I have a program with a button. When I click on this button a wx.dialog open. However on my new windows there are two button "Valider" and "Annuler", can you tell me why they...
0
by: Jerry Spence1 | last post by:
I have a picturebox on a form. All the events seems to work such as MouseEnter, MouseLeave etc. However I can not get the MouseWheel event to fire. I am hovering the mouse over the picture and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.