php - 提交带有自定义变量(提示)的表单的更好方法?

标签 php javascript

我想提交一个带有来自 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/

相关文章:

php - 使用 CSS 为 Moodle 表单中的选择器着色

javascript - 在 magento 中使用 "PIN/ZIP"检查器检查交付是否可用

javascript - 从服务器获取列表并打印由 span 标记包围的每个元素

php - Yii:如何让一个 Action 接收一个数组类型的get参数?

php - 输入字段值在选择不同的下拉菜单选项时更改

php - nslookup 查询的 shell_exec 空响应

javascript - 订阅具有自引用属性的 observable

javascript - 在 highcharts 上更改 y 轴

javascript - Firefox 中的 javascript 错误

javascript - 字母不从表中查询