question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Input checkbox value returns "on" in Internet Explorer 11

See original GitHub issue

Binding the value attribute of an input (checkbox) tag to a controller/component property seems broken in IE11.

See a minimal example here: https://cspanring.github.io/ie11-input-value/ (code)

template:

<input value={{inputValue}} type="checkbox" onclick={{action "getCheckboxValue"}}>My value is {{inputValue}}

controller:

inputValue: 3,

  actions: {
    getCheckboxValue() {
      let value = document.querySelector('input[type=checkbox]').value;
      // in IE11 value will be "on"
      alert('My value is: ' + value);
    },
  },

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jherdmancommented, Jun 27, 2018

Hey friends. I’ve worked around this in the past with radio buttons too (see #14712). The gist is that IE11 cares a lot about the order of your attributes. In general I’ve wrapped up native radio buttons in a component that has a didRender hook that looks like this:

  didRender() {
    // IE11 needs to have it value re-set
    this.element.value = this.value;
  },
1reaction
christianhaller3000commented, Jun 21, 2021

I stumbled on a solution for this. In IE11, if you set the value then change it to a checkbox, it will erase the value. So:

oCheckBox=document.createElement('input');
oCheckBox.name='testcheckbox';
oCheckBox.value='123456789';
oCheckBox.type='checkbox';
alert(oCheckBox.value);

This will show the correct value in Chrome, but will say ‘on’ in IE11. The following will ensure correct behaviour in both browsers:

oCheckBox=document.createElement('input');
oCheckBox.name='testcheckbox';
oCheckBox.type='checkbox';
oCheckBox.value='123456789';
alert(oCheckBox.value);

To quote someone in a chatroom when answering a hairy IE question, “did you properly light the incense? In which order did you chant and throw the chicken bones?” Instances like this make this question less silly the more insanity you find.

Thank you so much @thirdwheel You saved my day!

Read more comments on GitHub >

github_iconTop Results From Across the Web

IE 11 Checkbox Delay Bug? - MSDN - Microsoft
The issue we've noticed with IE 11 is that checking one of them causes a delay/pause before it's actually checked - in the...
Read more >
Internet Explorer 11 - Not able to check input type checkbox in ...
Any ideas that i can make checkbox to be checked by single click as normal in IE 11. Anyone facing this issue and...
Read more >
Checkbox change event issue with Internet Explorer 11
It appears that the 'checked' status of the check box is updated AFTER the 'change' event occurs; but only on IE11. This results...
Read more >
Checkbox not working in IE - JavaScript - SitePoint Forums
In IE nothing happens when i click the submit button, i don't get any error, even if the checkbox is ticked still nothing...
Read more >
checked - CSS: Cascading Style Sheets - MDN Web Docs
The :checked CSS pseudo-class selector represents any radio ( ) ... Checkbox element, when checked */ input[type="checkbox"]:checked ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found