0

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.

1

2 Answers 2

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();
Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

Yes: you could for example use jQuery to tie a JavaScript function to a button's onclick event. And then call the click() function on the button in the jQuery ready function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.