Submitting a Form Using JavaScript
You have a form with id theForm and a submit button placed within a div named placeOrder. The placeOrder() function is executed on the submit button click, replacing its innerHTML with "processing ..." and removing the button.
While the previous code effectively manipulates the div, it fails to submit the actual form. Adding document.theForm.submit(); to the placeOrder() function appeared unsuccessful.
Solution:
The issue lies in the form's name attribute. Since your form does not have id "theForm" set, Java cannot locate it and execute your submit command.
Assign the name "theForm" to your form as follows:
<form name="theForm">
With this modification, your document.theForm.submit(); command in placeOrder() will now successfully submit the amended form.
The above is the detailed content of Why Doesn't My JavaScript Form Submit?. For more information, please follow other related articles on the PHP Chinese website!