-1
I am trying to make my Final Total field(Tf) show the result of subtraction of other 2 fields, however I am not knowing how to calculate, someone would tell me how I do it?
	<script>
		function calcular() {
 			 var g1 = parseInt(document.getElementById('g1').value);
  			 var g2 = parseInt(document.getElementById('g2').value);
			  document.getElementById('gresult').innerHTML = g1 + g2;
			  document.getElementById('tg').innerHTML = g1 + g2;
			 var d1 = parseInt(document.getElementById('d1').value);
  			 var d2 = parseInt(document.getElementById('d2').value);
  			  document.getElementById('dresult').innerHTML = d1 + d2;
			  document.getElementById('td').innerHTML = d1 + d2;
			 var tg = parseInt(document.getElementById('tg').value);
			 var td = parseInt(document.getElementById('td').value);
			  document.getElementById('tf').innerHTML = tg - td;
			}
		</script><body>
		<h1> Fluxo de caixa </h1>
		<table border=1>
		<tr bgcolor="lightgreen">
			<th colspan = "3"> Ganhos (G) </th>
		</tr>
		<tr>
			<th> Data </th>
			<th> Descrição </th>
			<th> Valor </th>
		</tr>
		<tr>
			<td><input type = "date"></td>
			<td><input type = "text"></td>
			<td><input type = "text" id="g1" value=""></td>
		</tr>
		<tr>
			<td><input type = "date"></td>
			<td><input type = "text"></td>
			<td><input type = "text" id="g2" value="" onblur="calcular()"></td>
		</tr>
		<tr>
			<th colspan = "2" bgcolor="lightgreen"> Total </th>
			<td id="gresult"><input></td>
		</tr>
		</table>
<br><br><br><br>
		<table border=1>
		<tr bgcolor="red">
			<th colspan = "3"> Despesas (D) </th>
		</tr>
		<tr>
			<th> Data </th>
			<th> Descrição </th>
			<th> Valor </th>
		</tr>
		<tr>
			<td><input type = "date"></td>
			<td><input type = "text"></td>
			<td><input type = "text" id="d1" value=""></td>
		</tr>
		<tr>
			<td><input type = "date"></td>
			<td><input type = "text"></td>
			<td><input type = "text" id="d2" value="" onblur="calcular()"></td>
		</tr>
		<tr>
			<th colspan = "2" bgcolor="red"> Total </th>
			<td id="dresult"><input></td>
		</tr>
		</table>
<br><br><br><br>
		<table border=1>
		<tr>
			<th colspan = "2" bgcolor="lightblue"> Resumo </th>
		</tr>
		<tr>
			<td bgcolor="lightgreen"> Ganhos (G) </td>
			<td id="tg"><input type = "text"></td>
		</tr>
		<tr>
			<td bgcolor="red"> Despesas (D) </td>
			<td id="td"><input type = "text" onblur="calcular()"></td>
		</tr>
		<tr>
			<td bgcolor="lightblue"> Total Final </td>
			<td id="tf"><input></td>
		</tr>
		</table>
	</body