Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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 10:24 AM.

  • #2
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm don't know if this is a good way but it works... -

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

    with

    document.frm.Submit.disabled = false

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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*

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If (avail<0){ <---------

    .....Willy

  • #6
    New Coder
    Join Date
    Mar 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    New Coder
    Join Date
    Mar 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks willy.. jeeez ddint know it was going to be so sensitive...

  • #8
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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://codingforums.com/javascript-programming/54861-need-some-help-debugging.html


    Try to keep new threads to a minimum, if similar.
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •