Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2005, 09:20 AM   PM User | #1
arcmax
New Coder

 
Join Date: Mar 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
arcmax is an unknown quantity at this point
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..
arcmax is offline   Reply With Quote
Old 03-20-2005, 10:01 AM   PM User | #2
mark87
Senior Coder

 
Join Date: Dec 2004
Location: Essex, UK
Posts: 2,636
Thanks: 0
Thanked 0 Times in 0 Posts
mark87 is on a distinguished road
Hmm don't know if this is a good way but it works... -

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

with

document.frm.Submit.disabled = false
mark87 is offline   Reply With Quote
Old 03-20-2005, 10:24 AM   PM User | #3
arcmax
New Coder

 
Join Date: Mar 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
arcmax is an unknown quantity at this point
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
arcmax is offline   Reply With Quote
Old 03-20-2005, 11:57 AM   PM User | #4
codegoboom
Regular Coder

 
Join Date: Aug 2004
Location: codegoboom@yahoo.com
Posts: 999
Thanks: 0
Thanked 0 Times in 0 Posts
codegoboom is an unknown quantity at this point
Quote:
Originally Posted by arcmax
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.
__________________
*this message will self destruct in n-seconds*
codegoboom is offline   Reply With Quote
Old 03-20-2005, 12:00 PM   PM User | #5
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
If (avail<0){ <---------

.....Willy
Willy Duitt is offline   Reply With Quote
Old 03-20-2005, 12:08 PM   PM User | #6
arcmax
New Coder

 
Join Date: Mar 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
arcmax is an unknown quantity at this point
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 is offline   Reply With Quote
Old 03-20-2005, 12:10 PM   PM User | #7
arcmax
New Coder

 
Join Date: Mar 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
arcmax is an unknown quantity at this point
thanks willy.. jeeez ddint know it was going to be so sensitive...
arcmax is offline   Reply With Quote
Old 03-20-2005, 04:53 PM   PM User | #8
codegoboom
Regular Coder

 
Join Date: Aug 2004
Location: codegoboom@yahoo.com
Posts: 999
Thanks: 0
Thanked 0 Times in 0 Posts
codegoboom is an unknown quantity at this point
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.
__________________
*this message will self destruct in n-seconds*
codegoboom is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:37 PM.


Advertisement
Log in to turn off these ads.