...

View Full Version : need some help debugging...



arcmax
03-20-2005, 09:20 AM
<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

mark87
03-20-2005, 10:01 AM
Hmm don't know if this is a good way but it works... -

frm.getElementById("submit").disabled = false

with

document.frm.Submit.disabled = false

arcmax
03-20-2005, 10:24 AM
Error: missing ; before statement
Source File: http://127.0.0.1/amin/index2.html
Line: 18, Column: 14
Source Code:
If (avail<0){ <---------

This is what the js script console shows me

codegoboom
03-20-2005, 11:57 AM
If I did not have the statements (colored red), the script works very nicely.

element.getElementById is a problem (elements don't support it) use that method from document, if necessary.

Willy Duitt
03-20-2005, 12:00 PM
If (avail<0){ <---------

.....Willy

arcmax
03-20-2005, 12:08 PM
I have tried everything possible changed the position up and down..and it still says

Error: missing ; before statement
Source File: http://127.0.0.1/amin/index2.html
Line: 21, Column: 27
Source Code:
If (frm.balavail.value >=0){

The moment i remove the if statement the script works.

Need to know what I am doing wrong. ion for Becuase I cant seem to find a solution for it...

thanks
Apurva

arcmax
03-20-2005, 12:10 PM
thanks willy.. jeeez ddint know it was going to be so sensitive...

codegoboom
03-20-2005, 04:53 PM
Are these not all related to the same issue?

Need some help...i think it will be elementry..but it beats me.
http://www.codingforums.com/showthread.php?t=54802

Reposting with some clarity..hopefully...
http://www.codingforums.com/showthread.php?t=54849

totaling a form ---- URGENT HELP
http://www.codingforums.com/showthread.php?t=54856

need some help debugging...
http://www.codingforums.com/showthread.php?t=54861

Try to keep new threads to a minimum, if similar.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum