Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE 11 cannot submit an HTML form

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({
                command: 'insertAll',
                name: document.getElementById('name').value
            }));
        }
    }

    if (sara == 'POLY') {
        so.onopen = function() {
            so.send(JSON.stringify({
                command: '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?

like image 936
slevin Avatar asked Dec 21 '13 21:12

slevin


People also ask

Why is my HTML submit button not working?

Sometimes the problem is caused by old versions of the Javascript files, cached by your browser and can be fixed by clearing the browser cache. You can use the browser console of your browser for debugging. After the Javascript error is fixed, the submit button will automatically be enabled.

How do you submit a form in HTML?

The Submit Button The <input type="submit"> defines a button for submitting the form data to a form-handler. The form-handler is typically a file on the server with a script for processing input data. The form-handler is specified in the form's action attribute.

Can I use JavaScript to submit a form?

The JavaScript form submission can be used for object creation and various attributes can also be used. The attributes can be class, id, tag, etc. Calling by attributes is quite simple, we just need to place the symbols properly.

How do you submit a form using a tag?

You can use href=”#top” or href=”#” to link to the top of the current page. To use the anchor tag as submit button, we need the help of JavaScript. To submit the form, we use JavaScript . submit() function.


1 Answers

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 = '';
like image 52
Andy Avatar answered Sep 20 '22 00:09

Andy