I know that there is no way to use a query string to pass information into a form that uses the post method, but are there any other options? I am trying to use a link (or button) on one website to link to a page on another. In the process, the URL/button needs to send information to the target. The target website uses post, so I can't just use a query string to input my data. Is there some sort of button attribute that will let me send data to the fields in the target website? Thank you in advance.
EDIT: I should have also mentioned that I cannot use the form tag. For some reason, the environment I am using does not allow for some tags to be used.
This should solve your problem (tested it locally and confirmed form data was present) ... got starting point here https://stackoverflow.com/a/13678453/1946558
<button class="btn" id="go">Go </button>
<script type="text/javascript">
$(document).ready(function () {
$('#go').click(function () {
var form = document.createElement("form");
var input = document.createElement("input");
// where you want to post the data
form.action = "test";
form.method = "post";
// add your fields here
input.name = "id";
input.value = 'some data';
// then append
form.appendChild(input);
document.body.appendChild(form);
form.submit();
});
});
</script>
With a button:
<form action="http://example.com/target.php" method="post">
<input type="hidden" name="foo" value="bar" />
<input type="submit" />
</form>
With a link:
<form id="my_form" action="http://example.com/target.php" method="post">
<input type="hidden" name="foo" value="bar" />
</form>
<a href="#" onclick="document.getElementById('my_form').submit(); return false;">Submit</a>