troubleshooting Question

Javascript text field calculate and pass result and the difference to another two text fields

Avatar of sinanosan
sinanosan asked on
5 Comments1 Solution961 ViewsLast Modified:
How can I calculate text field value and pass result and the difference to another two text fields, the code I have is not updating when the values changed.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
   function compute()
   var num1 = parseInt(document.form1.fawour.value);
   var num2 = parseInt(document.form1.against.value);
   var computation = num1 - num2;
   document.form1.difference.value = computation;
   if (document.form1.difference.value == 'NaN')
            document.form1.difference.value = '';
            alert('Please enter score');
   function points()
   var num1 = parseInt(document.form1.fawour.value);
   var num2 = parseInt(document.form1.against.value);
    var computation = 1;

       if (document.form1.fawour.value = document.form1.against.value)
        document.form1.point.value = computation;

              <form name="form1">

  <input name="fawour" type="text" value="" size="4" maxlength="2">
  <input name="against" type="text" onChange="points();compute()" size="4" maxlength="2"/>
  <input type="text" name="point" id="point">
  <input type="text" name="difference" id="difference">

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros