Is there anyway to submit a POST variable, with name, to another page? I.e. form submission, as IF a button were clicked, but without having to click a button.
Asked
Active
Viewed 488 times
0
-
yes, take a look at this thread: http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit – groffhibbitz Jan 31 '12 at 18:46
2 Answers
2
There are many ways to do this - the easiest, library-free method probably being something like:
If your HTML looks like this (has at least the id, method, and action attributes)
<form id="myForm" method="post" action="post-target.php">
<input type="hidden" name="username" value="username" />
</form>
You can submit the form via javascript like this:
myForm = document.getElementById('myForm');
myForm.submit();

Kenan Banks
- 207,056
- 34
- 155
- 173
-
Yes, but I want the specific information contained in the button to be sent, too. I.e. I want to send a POST variable with the name "del" over to another page. – Steven Matthews Jan 31 '12 at 18:53