Home >Web Front-end >JS Tutorial >Why Doesn't My JavaScript Form Submit?

Why Doesn't My JavaScript Form Submit?

Barbara Streisand
Barbara StreisandOriginal
2024-11-10 11:48:02775browse

Why Doesn't My JavaScript Form Submit?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn