Q:

Calling a function using OnKeyup event doesn't work

I am try to call a Javascript function using onkeyup event but it didn't work I try using onClick Event that one works fine. How can I use onkeyup event to call a function?
<input value="" autocomplete="off" name="maxamf" id="maxamf" onkeyup="sum()"  class="" style="width:100px;color:#000;background:#FFF600;" type="text">

//javascript code
<script type="text/javascript">
   function sum()
   {
    document.getElementById('maxamf').value = document.getElementById('5t2').value / ((0.05 + 1)*(document.getElementById('slrratio2e').value)) ;
   }
</script>

A:

Check this it's working fine try to enter some thing in the field
<!DOCTYPE html>
<html>
<body>

<input value="" autocomplete="off" name="5t2" id="5t2" onkeyup="sum()" class="" style="width:200px;color:#000;background:#D1D3D4" type="text">

<input value="" autocomplete="off" onclick="sum()" name="slrratio2e" id="slrratio2e" class="" style=" width:100px;color:#000;background:#D1D3D4" type="text">

<input value="" autocomplete="off" name="maxamf" id="maxamf" onkeyup="sum()"  class="" style="width:100px;color:#000;background:#FFF600;" type="text">

//javascript code
<script type="text/javascript">
  function sum() {
    document.getElementById('maxamf').value = document.getElementById('5t2').value / ((0.05 + 1)*(document.getElementById('slrratio2e').value)) ;
  }
</script>
</body>
</html>

http://jsfiddle.net/mz6qvehn/

