Trying to get taxamt when taxbox checked to revert to 0.00 when unchecked

Hello,

I am a total newbie, so forgive me in advance as I am just learning javascript. I am putting together a small order form and the javascript code adds the tax (8.25%) and shipping (if any - entered by user) to the subtotal. But when I uncheck it, the taxamt amount stays in the box, but the subtotal changes back. Any ideas on how to have the taxamt back to 0 when unchecked.

<form name= "placeOrder">
<table width="70%" border="1" cellpadding="5" cellspacing="5" bordercolor="#e2e2e2">
  <tr>
    <td>fabric number</td>
    <td>yardage</td>
    <td>price</td>
    <td>amount</td>
    <td>sample size</td>
  </tr>
  <tr>
	<td align="center"><input name="fab1" type="text" id="fab1"></td>
    <td align="center">	<input type = "text" name = "qty1" id = "qty1" onchange = "doMath(1)"></td>
    <td align="center">	<input type = "text" name = "cost1" id = "cost1" onChange = "doMath(1)"></td>
    <td align="center"><input type = "text" name = "amount1" id = "amount1" value = "0.00" readonly></td>
    <td align="center"><input name="sample1" type="text" id="sample1"></td>
  </tr>
  <tr>
    <td align="center"><input name="fab2" type="text" id="fab2"></td>
    <td align="center"><input type = "text" name = "qty2" id = "qty2" onChange = "doMath(2)"></td>
    <td align="center"><input type = "text" name = "cost2" id = "cost2" onChange = "doMath(2)" ></td>
    <td align="center"><input type = "text" name = "amount2" id = "amount2" value = "0.00" readonly></td>
    <td align="center"><input name="sample2" type="text" id="sample2"></td>
  </tr>
  <tr>
    <td align="center"><input name="fab3" type="text" id="fab3"></td>
    <td align="center"><input type = "text" name = "qty3" id = "qty3" onChange = "doMath(3)"></td>
    <td align="center"><input type = "text" name = "cost3" id = "cost3" onChange = "doMath(3)"></td>
    <td align="center"><input type = "text" name = "amount3" id = "amount3" value = "0.00" readonly></td>
    <td align="center"><input name="sample3" type="text" id="sample3"></td>
  </tr>
  <tr>
    <td height="31">&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">Texas sales tax <input type="checkbox" id="taxbox" name="taxbox" onclick="doMath(1)">
    </td>
    <td align="center"><input type="text" name="taxamt" id="taxamt" value="0.00" onChange="doMath()"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">subtotal:</td>
    <td align="center"><input type="text" name="GdTotal" value="0.00" id="GdTotal" readonly></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">shipping &amp; handling:</td>
    <td align="center"><INPUT type="text" id="shipamt" value="0.00" name="shipamt" onChange="doMath()">
    </td>
	<td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>invoice will be emailed when shipping cost is calculated</td>
	<td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">Total:</td>
    <td><input type="text" name="GdTotal" value="0.00" id="GdTotal" readonly></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>

<script type='text/javascript'>

			function doMath(which){
			var gdtot = 0;
			var tx //" Excluding TX Sales tax";
			var units = document.getElementById("qty"+which).value;
			var shipamt = document.getElementById("shipamt").value;
			shipamt = parseFloat( shipamt );

			if (isNaN(units)) { document.getElementById("qty"+which).value = ""}
			if (isNaN(shipamt)) {
				document.getElementById("shipamt").value = "";
				shipamt = 0; // so no error when added to gdtot
			}

			var rate = document.getElementById("cost"+which).value;
			var total = units * rate;
			if(!isNaN(total)) {
			var total2dp = total.toFixed(2);
			document.getElementById("amount"+which).value = total2dp;
			for (var i = 1; i <=3; i++) {
			x = document.getElementById("amount" + i).value;
			gdtot = +x +gdtot;  // ensure x is a number
			}
			if (document.getElementById("taxbox").checked) {
				var taxamt = gdtot * 0.0825;
				document.getElementById("taxamt").value = taxamt.toFixed(2);
				gdtot += taxamt;
			}
			gdtot += shipamt;
			document.getElementById("GdTotal").value = gdtot.toFixed(2);
			}
			}



</script>

Solved