Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Location
    Chicago, IL,USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Could someone please help me debug this script

    I can't figure out what the problem is with this script but it displays a page error when i try to enter information. I would really appreciate any help.

    Thank you,
    Kim


    <SCRIPT>

    function dp(price)

    {

    string = "" + price;

    number = string.length - string.indexOf('.');

    if (string.indexOf('.') == -1)

    return string + '.00';

    if (number == 1)

    return string + '00';

    if (number == 2)

    return string + '0';

    if (number > 3)

    return string.substring(0,string.length-number+3);

    return string;

    }



    function calculate()

    {

    document.calcform.matextension.value = dp((document.calcform.matunits.value)*(document.ca lcform.matunitcost.value))

    document.calcform.mtxextension.value = dp((document.calcform.mtxunits.value)*(document.ca lcform.mtxunitcost.value))

    document.calcform.equextension.value = dp((document.calcform.equunits.value)*(document.ca lcform.equunitcost.value))

    document.calcform.conextension.value = dp((document.calcform.conunits.value)*(document.ca lcform.conunitcost.value))

    document.calcform.othextension.value = dp((document.calcform.othunits.value)*(document.ca lcform.othunitcost.value))

    document.calcform.lab2extension.value = dp((document.calcform.lab2units.value)*(document.c alcform.lab2unitcost.value))

    document.calcform.lab3extension.value = dp((document.calcform.lab3units.value)*(document.c alcform.lab3unitcost.value))

    document.calcform.lab4extension.value = dp((document.calcform.lab4units.value)*(document.c alcform.lab4unitcost.value))

    document.calcform.lab5extension.value = dp((document.calcform.lab5units.value)*(document.c alcform.lab5unitcost.value))

    document.calcform.lab9extension.value = dp((document.calcform.lab9units.value)*(document.c alcform.lab9unitcost.value))

    document.calcform.lab10extension.value = dp((document.calcform.lab10units.value)*(document. calcform.lab10unitcost.value))

    document.calcform.lab13extension.value = dp((document.calcform.lab13units.value)*(document. calcform.lab13unitcost.value))

    document.calcform.lab14extension.value = dp((document.calcform.lab14units.value)*(document. calcform.lab14unitcost.value))

    document.calcform.lab15extension.value = dp((document.calcform.lab15units.value)*(document. calcform.lab15unitcost.value))

    document.calcform.lab16extension.value = dp((document.calcform.lab16units.value)*(document. calcform.lab16uunitcost.value))

    document.calcform.lab17extension.value = dp((document.calcform.lab17units.value)*(document. calcform.lab17unitcost.value))

    document.calcform.lab18extension.value = dp((document.calcform.lab18units.value)*(document. calcform.lab18unitcost.value))

    document.calcform.lab19extension.value = dp((document.calcform.lab19units.value)*(document. calcform.lab19unitcost.value))

    document.calcform.lab20extension.value = dp((document.calcform.lab20units.value)*(document. calcform.lab20unitcost.value))

    document.calcform.lab21extension.value = dp((document.calcform.lab21units.value)*(document. calcform.lab21unitcost.value))

    document.calcform.lab22extension.value = dp((document.calcform.lab22units.value)*(document. calcform.lab22unitcost.value))

    document.calcform.lab23extension.value = dp((document.calcform.lab23units.value)*(document. calcform.lab23unitcost.value))

    document.calcform.lab24extension.value = dp((document.calcform.lab24units.value)*(document. calcform.lab24unitcost.value))

    document.calcform.lab25extension.value = dp((document.calcform.lab25units.value)*(document. calcform.lab25unitcost.value))

    document.calcform.lab26extension.value = dp((document.calcform.lab26units.value)*(document. calcform.lab26unitcost.value))

    document.calcform.lab27extension.value = dp((document.calcform.lab27units.value)*(document. calcform.lab27unitcost.value))

    document.calcform.lab28extension.value = dp((document.calcform.lab28units.value)*(document. calcform.lab28unitcost.value))

    document.calcform.parkextension.value = dp((document.calcform.parkunits.value)*(document.c alcform.parkunitcost.value))

    document.calcform.nonbillextension.value = dp((document.calcform.nonbillunits.value)*(documen t.calcform.nonbillunitcost.value))

    document.calcform.totalestcost.value = dp(eval(document.calcform.matextension.value) + eval(document.calcform.mtxextension.value) + eval(document.calcform.conextension.value) + eval(document.calcform.othextension.value) + eval(document.calcform.lab2extension.value) + eval(document.calcform.lab3extension.value) + eval(document.calcform.lab4extension.value) + eval(document.calcform.lab5extension.value) + eval(document.calcform.lab9extension.value) + eval(document.calcform.lab10extension.value) + eval(document.calcform.lab13extension.value) + eval(document.calcform.lab14extension.value) + eval(document.calcform.lab15extension.value) + eval(document.calcform.lab16extension.value) + eval(document.calcform.lab17extension.value) + eval(document.calcform.lab18extension.value) + eval(document.calcform.lab19extension.value) + eval(document.calcform.lab20extension.value) + eval(document.calcform.lab21extension.value) + eval(document.calcform.lab22extension.value) + eval(document.calcform.lab23extension.value) + eval(document.calcform.lab24extension.value) + eval(document.calcform.lab25extension.value) + eval(document.calcform.lab26extension.value) + eval(document.calcform.lab27extension.value) + eval(document.calcform.lab28extension.value) + eval(document.calcform.parkextension.value) + eval(document.calcform.nonbillextension.value))

    }



    </SCRIPT>

  2. #2
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Coppell, Texas, USA
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Could someone please help me debug this script

    What's the error message? I didn't see anything wrong with the script, and dp seems to do it's job just fine.

    Here's a tip: Debug client-side JavaScript in Netscape 4.x using the JavaScript Console to view the errors (type java script: in the address bar and hit enter to bring up the console). Netscape does a good job of locating the errors in scripts. And since it's less forgiving than IE, you'll often find problems before your users do.

    It also saves you having to install MS de######, which can become a real pain if you need to debug ASP pages.

    HTH

Posting Permissions

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