我想提交一个带有来自 prompt()
函数的自定义变量的表单。
提交表单使用代码
document.formname.submit();
但这只会提交表单,我想要的是:
var iInvoiceID = prompt("Please enter the invoice ID");
document.formname.submit(); // But it should send iInvoiceID within $_POST aswell
一种方法是:在出现提示后,将输入类型设置为“隐藏”到iInvoiceID
的值,然后提交表单。但是有没有更好/更清洁的方法来做到这一点?
最佳答案
不,按照你建议的方式,
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?
做你需要做的最好、最干净。
编辑:
至于您的编辑,我认为 document.formname.submitbutton1.click();
应该可以完成这项工作。
关于php - 提交带有自定义变量(提示)的表单的更好方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7204505/