js提交按钮,显示“提交查询”,不起作用,仅在IE Edge / IE *中

时间:2016-07-27 17:33:12

标签: javascript forms internet-explorer submit microsoft-edge

此表单由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);

1 个答案:

答案 0 :(得分:0)

从评论中得出,解决方案是改变这一点:

/*submit button */
var submitThis = document.createElement("input");
    submitThis.setAttribute('value',"Submit");
    submitThis.setAttribute('type',"submit");
    submitThis.setAttribute('name',"SendFormAction");

对此:

/*submit button */
var submitThis = document.createElement("input");
    submitThis.setAttribute('type',"submit"); // <-- Set type before value
    submitThis.setAttribute('value',"Submit");
    submitThis.setAttribute('name',"SendFormAction");