Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet explorer oninput function not working

I have a problem with IE. I created form with calculation in JS it use input type range. here is a link to jsfiddle: http://jsfiddle.net/vu378xh9/8/ And html code:

<form action="" method="post" name="checkincome">
<label>Persons</label>
<input id="persons" name="persons" type="range" min="1" max="41" value="10" oninput="chckIncome();" />
<p id="personsvalue">10</p>
<br />
<label title="">Sale per person</label>
<input id="starters" name="starters" type="range" value="21.2" min="0.0" max="100.0" step="5" oninput="chckIncome();" />
<p id="startersvalue">21</p>
<br />
<p id="resultsvalue"></p>
<p style="text-align:center; padding-top:10px;">
    <input name="Reset" class="btn btn-large" type="reset" value="Reset" />
</p>

Javascript:

function chckIncome() {
var price = 49.9;
var regular = 199.9;
var form = document.forms.checkincome;
var x = parseFloat(form.persons.value);
var y = parseFloat(form.starters.value);
var z = 2.5;
var sum1 = (x * y) * price;
var sum2 = ((x * y) * z) * regular;
var sum3 = ((sum1 + sum2) * 0.25).toFixed(0);
sum3 = sum3.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
document.getElementById('personsvalue').innerHTML = form.persons.value;
document.getElementById('startersvalue').innerHTML = form.starters.value;
document.getElementById('resultsvalue').innerHTML = sum3 + " kr";
}

It works in all browsers except IE. Can someone have idea how to fix it?

like image 224
gzres Avatar asked Sep 19 '14 08:09

gzres


1 Answers

oninput is not supported in older Internet Explorer versions. Since oninput triggers when you make input you could use other events to do pretty much the same thing.

Since you are using range I would suggest to use onmousemove.

<input type="range" id="testInput" onmousemove="test()">

<p id="demo"></p>

<script>
   function test() {
      var x = document.getElementById("testInput").value;
      document.getElementById("demo").innerHTML =  x;
   }
</script>
like image 58
Afsa Avatar answered Oct 21 '22 08:10

Afsa