|
need some help debugging...
<script language="javascript">
function addAll(){
var frm = document.f;
var len = parseInt(frm.count.value);
var bal = parseFloat(frm.balance.value);
var total = 0.00;
var avail= 0.00;
for (var i=1;i<len;i++){
objAmt = eval("frm.AMT"+i);
total+=parseFloat(objAmt.value);
avail=bal-total;
If (avail>0){
frm.getElementById("submit").disabled = false;
}
}
frm.tot.value=Math.floor(total*100)/100;
frm.balavail.value=Math.floor(avail*100)/100;
}
</script>
............
Print("<form METHOD=\"POST\" ACTION=\"index2.html\" name=\"f\">\n");
<input type=\"hidden\" name=\"count\" value=\"$numrows\">
<input name=\"tot\" size=\"6\" value=\"00.00\" onfocus=\"this.blur()\" readonly>
<input name=\"balavail\" size=\"6\" value=\"$row[balance]\" onfocus=\"this.blur()\" readonly>
$i=1;
While ($row2 = MYSQL_FETCH_ARRAY($r2)){
<input type=\"textbox\" size=\"5\" id=\"Amt\" name=\"AMT$i\" value=\"00.00\" onkeydown=\"if (isNaN(this.value)) this.value='00.00'\" onkeyup=\"addAll()\">
$i++;
}
<input id=\"submit\" name=\"submit\" TYPE=\"submit\" VALUE=\"Settle\" disabled=\"disabled\">
If I did not have the statements (colored red), the script works very nicely. The idea of those lines is to see if bal is negative or not and then change the state of the submit button, clickable if positive or disbaled if negative.
Hope you guys can help out
thanks
apurva
Last edited by arcmax; 03-20-2005 at 09:24 AM..
|