2021年3月19日星期五

How to calculate using input from div input tags

I'm lost working on a computer science assignment and my teacher isn't available to help. I have a simple JS program that's supposed to subtract values from user input.

Here is my code:

function calculate(){          var exspendin = document.getElementById('exspendin');          var avfundin = document.getElementById('avfundin');          var total = 'exspendin' - 'avfundin';          //var total = math.subtract('avfundin', 'exspendin')          document.getElementById('calc');          window.alert('total');      }
<div><input type="text" id="avfundin" height="79" width="328" y="153.5" x="235.99999"  value="Input Available Funds"><div>  <div><input type="text" id="exspendin" height="79" width="328" y="292.5" x="235.99999" value="Input Expected Spending"><div>

When I run, it prints "total" instead of the difference of the user input. How would I get it to do that.

https://stackoverflow.com/questions/66717773/how-to-calculate-using-input-from-div-input-tags March 20, 2021 at 10:45AM

没有评论:

发表评论