I’d like to submit a form with a custom variable from the prompt() function.
Submitting a form uses the code
document.formname.submit();
But that will just submit the form, what I want is:
var iInvoiceID = prompt("Please enter the invoice ID");
document.formname.submit(); // But it should send iInvoiceID within $_POST aswell
One way could be: after the prompt, set an input type = ‘hidden’ to iInvoiceID‘s value, and then submit the form. But is there a better/cleaner way todo this?
No, the way you suggested,
Is the best and cleanest of doing what you need.
Edit:
As for your edit, I think
document.formname.submitbutton1.click();should do the job.