Reading time: 2 – 2 minutes

The unreliable IE
(Photo: BlubrNL)

I was stuck with this problem today, and thought I should write a blog post about it, so should anyone encounter the same thing, they won’t waste time trying to track exactly what’s happening.

Basically it was flagged to me this morning by my project manager that when you tried to submit a form that calls for a report generation using the enter key, the report would not be generated.

I then tried the same pattern (on Firefox), and obviously got results. Project managers are known to use Internet Explorer, so I dusted off my IE 8, and tried the same thing.

Obviously got the same error, the report would not be generated.
I then started to compare what was being passed, once you tried to submit the form by clicking on the submit button, or by hitting enter.

Here are the dumps:
By clicking the submit button:
Generate Report

By hitting the enter key:
Generate Report on IE

For those who can’t spot the difference (believe me, it took me a while to spot it), when you submit using the enter key, it DOES NOT pass the button (generate) as an attribute.

Turns out this report relies on the variable called “generate” to be passed, so it knows when to query the database, and display the data.

Lesson learned, never rely on button fields being passed to decide if data will be shown or not.

Be Sociable, Share!

5 Responses to “The unreliable Internet Explorer”

  1. Roland Collins says:

    To be fair, HTML does not define a required behavior for what to do with the Enter key. In fact, it’s inconsistent depending on the type of field that you’re focused on in FireFox. Hitting Enter on textarea and select fields does not submit the form – only the input tag causes this behaviour.

    Just to play the devil’s advocate here:

    You didn’t actually click the button – why would the button have a value? How are you able to tell that a button was clicked vs. the enter key being pressed on the server side if the button values are always transmitted?

    Let’s look at another example. Create a cfm with this code:

    <cfdump var=”#form#”>

    <form method=”post”>
    <input type=”text” name=”myInput” value=”i was here”>
    <input type=”submit” name=”mySubmit” value=”submit me!”>
    <input type=”submit” name=”mySubmit” value=”submit me too!”>
    </form>

    In FireFox, what would you expect the value of form.mySubmit to be if you just hit enter in the text box? Going by the logic that says that the submit button values should be transmitted, you would expect *both* values to be transmitted. In fact, it’s only the *first* value that is transmitted.

    I personally prefer the behavior of not sending a submit button’s value if it was not clicked. In theory, it actually provides you more detail about the user’s interaction with the form on the server side. In reality, we jsut have to wind up making IE behave like FireFox, or things don’t work consistently.

  2. Roland Collins says:

    Also – there’s a good discussion of this behavior on stackoverflow.

    http://stackoverflow.com/quest.....determined

  3. [...] Zobacz resztę artykułu: Internet explorer and submit button bug | Technology | Marcos … [...]

  4. One of the reason why I always pass a hidden form element called trigger or whatever. I never rely on the button anymore.

  5. Jay Valdez says:

    hey marcos, just speaking in general regarding the topic. as a front end coder, the IE enterprise does suck specially in layouts, im not really surprised that the new IE does look top notch but there are still unexplored areas which improvements are needed.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>