简体   繁体   中英

js submit button displaying 'submit query', not functioning, only in IE Edge / IE *

Have this form being generated by javascript. It works on every browser other than IE Edge and previous versions of IE. I've researched this and looked into it but am coming up with no answers. It works in every other browser tested, but in IE the submit button value is " submit query " and fails to submit the form. This javascript is inline on a page below the tag. I'm stumped. Any assistance is greatly appreciated.

/*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);

Taken from the comments, the solution is to change this:

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

To this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM