【发布时间】:2016-07-27 17:33:12
【问题描述】:
让这个表单由 javascript 生成。它适用于除 IE Edge 和以前版本的 IE 之外的所有浏览器。我已经对此进行了研究并进行了调查,但没有提出任何答案。它适用于所有其他经过测试的浏览器,但在 IE 中,提交按钮值为“提交查询”并且无法提交表单。此 javascript 内嵌在标签下方的页面上。我难住了。非常感谢任何帮助。
/*generate the form itself */
var loginForm = document.createElement("form");
loginForm.setAttribute('id',"editDataForm");
loginForm.setAttribute('method',"post");
loginForm.setAttribute('action',"submit.cfm");
/*some basic text field */
var someTextBox = document.createElement("input");
someTextBox.setAttribute('type',"text");
someTextBox.setAttribute('name',"username");
/*submit button */
var submitThis = document.createElement("input");
submitThis.setAttribute('value',"Submit");
submitThis.setAttribute('type',"submit");
submitThis.setAttribute('name',"SendFormAction");
/*append the textbox to the form */
loginForm.appendChild(someTextBox);
/*append the submit button to the form */
loginForm.appendChild(submitThis);
/*get the div where the form will generate itself */
var loginDiv = document.getElementById("submitFormArea");
/*append the form to the div */
loginDiv.appendChild(loginForm);
【问题讨论】:
-
Moving
valueaftertype为我解决了这个问题。 -
哇。同样在这里。这非常简单,但令人困惑。
-
似乎设置
type会导致元素“重置”。哪种有意义,因为从默认(文本输入)更改为提交(按钮)是一个巨大的变化。
标签: javascript forms internet-explorer submit microsoft-edge