need help to rewrite script (at the bottom half) so that ex01 - deposit01 = balance01




<script type="text/javascript" language="javascript">function stripBlanks(fld) {var result = "";var c = 0;for (i=0; i < fld.length; i++) {if (fld.charAt(i) != " " || c > 0){ result += fld.charAt(i); if (fld.charAt(i) != " ") c = result.length;}} return result.substr(0,c);}
function budget(thisform) {
var result = 0;
var in1 = stripBlanks(thisform.in1.value);
if (in1 != '' && in1 != parseFloat(in1)) {alert("Total Budget Amount must be numeric");thisform.in1.focus();return false;}
result += Number(in1);
var ex01 = stripBlanks(thisform.ex01.value);
if (ex01 != '' && ex01 != parseFloat(ex01)) {alert("Item 1 must be numeric");thisform.ex01.focus();return false;}
result -= Number(ex01);
var ex02 = stripBlanks(thisform.ex02.value);
if (ex02 != '' && ex02 != parseFloat(ex02)) {alert("Item 2 must be numeric");thisform.ex02.focus();return false;}
result -= Number(ex02);
thisform.res.value = result;}
function calculate_balance_amount1() {
dep1 = document.getElementById("deposit01").value;
dep1 = stripBlanks(dep1);
if (dep1 != '' && dep1 != parseFloat(dep1)) {
alert("Amount deposited must be numeric");
which.value = "";
which.focus();
return false;
}
deptot = parseFloat(dep1);
document.getElementById("balance01").value = deptot.toFixed(2);
}


function calculate_balance_amount2() {
dep2 = document.getElementById("deposit02").value;
dep2 = stripBlanks(dep2);
if (dep2 != '' && dep2 != parseFloat(dep2)) {
alert("Amount deposited must be numeric");
which.value = "";
which.focus();
return false;
}
dep1 = parseFloat(dep1);
dep2 = parseFloat(dep2);
deptot = (dep1 + dep2);
document.getElementById("balance02").value = deptot.toFixed(2);
}
</script>
<form name="budcalc">
<table width="669" border="0" align="center" class="budcalc">
<tr>
<th colspan="2"><h3 align="center"> Budget Calculator</h3></th>
</tr>
<tr>
<th colspan="2" align="left"> </th>
</tr>
<tr>
<td width="102" align="right">Enter your Total Budget Amount :</td>
<td width="167" align="left"><input type="text" name="in1" size="10" /></td>
</tr>
<tr>
<th colspan="2" align="left">Item </th>
</tr>
<tr>
<td align="right">Item 1 :</td>
<td colspan="2"><input name="ex01" type="text" class="inputbox" id="ex01" size="10" /></td>
<td width="69" align="right">deposit 1:</td>
<td colspan="2"><input name="deposit01" type="text" class="inputbox" id="deposit01" onchange="calculate_balance_amount1();" size="10" />
</td>
<td width="78" align="right">balance 1:</td>
<td width="143"><input type="text" name="balance01" id = "balance01" size="10" readonly="readonly" /></td>
</tr>
<tr>
<td align="right">Item 2 :</td>
<td colspan="2"><input name="ex02" type="text" class="inputbox" id="ex02" size="10" /></td>
<td align="right">deposit 2:</td>
<td colspan="2"><input name="deposit02" type="text" class="inputbox" id="deposit02" onchange="calculate_balance_amount2();" size="10" />
</td>
<td align="right">balance 2:</td>
<td width="143"><input type="text" name="balance02" id = "balance02" size="10" readonly="readonly" /></td>
</tr>
<tr>
<td> </td>
<td><input name="button" type="button" onclick="budget(budcalc);return false;" value="Calculate" /></td>
</tr>
<tr>
<td align="right"><b>You still have :</b></td>
<td align="left"><input type="text" name="res" size="10" readonly="readonly" />
left to spend</td>
</tr>
</table>
</form>