Let's say we have the following form:
<form action="someaction" method="post">
<input type="hidden" id="input_example" name="input_example" value="">
<button type="submit" id="show-selected" class="btn btn-primary">Submit</button>
</form>
The value before clicking on the Submit button is "", but I would like that before sending the form, when clicking on the submit button, to be able to inject a value into the input from JavaScript.
For example:
$( "#show-selected" ).click(function() {
//add some value to the input, like "abc" and then submit the form
//I guess we could do something like:
//document.getElementById("#input_example").value = "abc";
//
});
But how can we do so that the value is injected before sending the form and not after?