ranbir ranbir - 1 year ago 94
PHP Question

how to give name in auto submit form javascript

this is my code that i am using to submit form with post value

<form action="<?php echo DOMAIN; ?>contact/booking-form.php" method="post">
<input type="text" name="name" value="<?php echo $name; ?>" />
<input type="text" name="email" value="<?php echo $email; ?>" />
<input type="submit" name="submit" id="submit" />

Can anybody help me to pass name="submit" value of submit button to another page?

Answer Source

A submit button is only going to be a successful control if it is used to submit the form (and even then only if it has a name and a value … which yours does not).

If you want submit=submit in your form data when you submit the form with JavaScript, then don't use a submit button to put that data in the form in the first place. Use a hidden input.

<input type="submit">
<input type="hidden" name="submit" id="submit" value="submit">

Then you have two other problems.

First, submit is a method of form elements, not inputs. So you need to change your script to call the right element.


Second, if a form has a control called submit then that will clobber the submit method. So you need to get one from a different form (not supported in old versions of Internet Explorer):

var form = document.getElementById('submit').form;
var submit_method = document.createElement("form").submit;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download