最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - IE 11 cannot submit an HTML form - Stack Overflow

programmeradmin9浏览0评论

I have this HTML form

<form name="nextform" action="anotherpage.php" method="post" enctype="multipart/form-data">
    <input name="pinid" id="pinid" type="hidden">
    <input type="submit" name="submit" id="post" value="Lets Go" class="formButtonMap">
</form>

pinid dynamically gets a value using JavaScript. When it gets a value I alert it and it works.

But, when I click the Lets Go button, nothing happens. I see the Internet Explorer loading for a couple of minutes and then I get the message “The webpage does not respond”. If I hit refresh it goes to anotherpage.php but the values from the form did not arrive to the server.

Rarely shows this message:

Visual Studio Just-In-Time Debugger

An unhandled win32 exception occured in iexplorer.exe [688]

Possible Debuggers :

New Instance of Microsoft Visual Studio 2012

This behavior is observed only in Internet Explorer 11.0.2. The form works in older versions of Internet Explorer and also in Chrome and Firefox. I get no errors in IE’s console.

Here is the JavaScript code, placed above the form:

// called when another button is clicked - basicaly is websockets
function save() {
    var so = new WebSocket("ws://localhost:8000");
    so.onerror = function (evt) {
        alert('problem');
    }

    if (sara == 'LINES') {
        so.onopen = function() {
            so.send(JSON.stringify({
                mand: 'insertAll',
                name: document.getElementById('name').value
            }));
        }
    }

    if (sara == 'POLY') {
        so.onopen = function() {
            so.send(JSON.stringify({
                mand: 'insertHalf',
                name: document.getElementById('name').value
            }));
        }
    }

    so.onmessage = function (evt) {
        var received_msg = evt.data;

        document.getElementById("next").style.display = "block";
        document.getElementById("name").value = "";
        document.getElementById("descr").value = "";
        clearLinks();

        document.getElementById("pinid").value = received_msg;
        alert(document.getElementById("pinid").value); // works

        so.close();
    }
}

I tried to edit the code using document.getElementById("nextform").submit();, problem is still there.

Is it me? Is it a bug? What am I missing?

I have this HTML form

<form name="nextform" action="anotherpage.php" method="post" enctype="multipart/form-data">
    <input name="pinid" id="pinid" type="hidden">
    <input type="submit" name="submit" id="post" value="Lets Go" class="formButtonMap">
</form>

pinid dynamically gets a value using JavaScript. When it gets a value I alert it and it works.

But, when I click the Lets Go button, nothing happens. I see the Internet Explorer loading for a couple of minutes and then I get the message “The webpage does not respond”. If I hit refresh it goes to anotherpage.php but the values from the form did not arrive to the server.

Rarely shows this message:

Visual Studio Just-In-Time Debugger

An unhandled win32 exception occured in iexplorer.exe [688]

Possible Debuggers :

New Instance of Microsoft Visual Studio 2012

This behavior is observed only in Internet Explorer 11.0.2. The form works in older versions of Internet Explorer and also in Chrome and Firefox. I get no errors in IE’s console.

Here is the JavaScript code, placed above the form:

// called when another button is clicked - basicaly is websockets
function save() {
    var so = new WebSocket("ws://localhost:8000");
    so.onerror = function (evt) {
        alert('problem');
    }

    if (sara == 'LINES') {
        so.onopen = function() {
            so.send(JSON.stringify({
                mand: 'insertAll',
                name: document.getElementById('name').value
            }));
        }
    }

    if (sara == 'POLY') {
        so.onopen = function() {
            so.send(JSON.stringify({
                mand: 'insertHalf',
                name: document.getElementById('name').value
            }));
        }
    }

    so.onmessage = function (evt) {
        var received_msg = evt.data;

        document.getElementById("next").style.display = "block";
        document.getElementById("name").value = "";
        document.getElementById("descr").value = "";
        clearLinks();

        document.getElementById("pinid").value = received_msg;
        alert(document.getElementById("pinid").value); // works

        so.close();
    }
}

I tried to edit the code using document.getElementById("nextform").submit();, problem is still there.

Is it me? Is it a bug? What am I missing?

Share Improve this question edited Jan 3, 2014 at 20:38 Palec 13.6k8 gold badges75 silver badges142 bronze badges asked Dec 21, 2013 at 21:31 slevinslevin 3,88621 gold badges76 silver badges140 bronze badges 6
  • why do you need a value in the submit input? – w3jimmy Commented Dec 26, 2013 at 2:17
  • @w3jimmy That's the "name" of the text that the users sees. It could be "Download" or "Go back". You suggest I should delete it? – slevin Commented Dec 26, 2013 at 14:20
  • Your page actually posts if you see that, so problem doesnt seem like to be the button itself. Could something be wrong with the redirected page? – Kuzgun Commented Dec 30, 2013 at 15:52
  • Since you aren't uploading a file, maybe try it without the enctype="multipart/form-data"? – adam0101 Commented Dec 30, 2013 at 17:59
  • 1 By the description, most likely the problem is on anotherpage.php, post your form to another (preferably empty) page and see if it does the same. Also posting the code of anotherpage.php would help. – Rafael Commented Dec 30, 2013 at 19:42
 |  Show 1 more ment

6 Answers 6

Reset to default 4 +50

I believe this is a bug when setting form values to empty in IE.

  • IE Bug Report

I would suggest trying a different method to resetting the form values, I have used this method in the past:

document.getElementById('name').parentNode.innerHTML = '';

Maybe not your issue, but:

<input type="submit" name="submit" ... >

Giving a form control a name of submit will replace the form's submit method with a reference to the control, so calling form.submit() will attempt to "call" the input.

hi might be problem in your code you miss to add id in form and you try to access form by it's id that you not define.

document.getElementById("nextform").submit();

its required

<form name="nextform" id="nextform" action="anotherpage.php" method="post" enctype="multipart/form-data">

...
...
...

</form>

Trace through what happens in the anotherpage.php page when it receives the postback, evt.data might not be encoded as you expect (is it binary or text, if text, is it utf-8).

Postback to a different page where all it does is output the posted back values.

Does the socket close throw an exception?

 so.close();

My original code has a form with more than 5 fields. When submitted calls the save(). save() function also clears the fields using JS.

There is a bug in IE11, that crashes the browser if you try to clear more than 5 fields , using JS. See here , there is workaround.

That bug crashes the first form, then the nextform form and also the browser. I APOLOGISE for not posting all my code, I did not know it had to do with the first form.

Because I thought the same piece of code had two different problems , I posted another question, very similar , here

In my case the input button had the same ID and NAME. So you can check if they are the same and if indeed they are the same use different value for one of the parameters.

I hope it helps.

发布评论

评论列表(0)

  1. 暂无评论