SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru XraySierra's Avatar
    Join Date
    Jan 2002
    Location
    Ontario, Canada
    Posts
    850
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Modifying Add Program to Stop at 10,000?

    I currently have a rebate calculation form on one of my sites. However, the rebates only go up to $10,000 even though there is more available. How can I modify the code below to print out no more then $10,000?
    Code:
    if(document.rebateCalc.basementHeader.checked == true) { total += parseFloat(document.rebateCalc.basementHeader.value); }
        if(document.rebateCalc.crawlSpaceA.checked == true) { total += parseFloat(document.rebateCalc.crawlSpaceA.value); }
        if(document.rebateCalc.crawlSpaceB.checked == true) { total += parseFloat(document.rebateCalc.crawlSpaceB.value); }
        if(document.rebateCalc.crawlSpaceC.checked == true) { total += parseFloat(document.rebateCalc.crawlSpaceC.value); }
        if(document.rebateCalc.floor.checked == true) { total += parseFloat(document.rebateCalc.floor.value); }
        if(document.rebateCalc.doorsA.checked == true) { total += parseFloat(document.rebateCalc.doorsA.value); }
        if(document.rebateCalc.doorsB.checked == true) { total += parseFloat(document.rebateCalc.doorsB.value); }
        if(document.rebateCalc.water.checked == true) { total += parseFloat(document.rebateCalc.water.value); }
        if(document.rebateCalc.hotWaterA.checked == true) { total += parseFloat(document.rebateCalc.hotWaterA.value); }
        if(document.rebateCalc.hotWaterB.checked == true) { total += parseFloat(document.rebateCalc.hotWaterB.value); }
        if(document.rebateCalc.hotWaterC.checked == true) { total += parseFloat(document.rebateCalc.hotWaterC.value); }
        if(document.rebateCalc.hotWaterD.checked == true) { total += parseFloat(document.rebateCalc.hotWaterD.value); }
        if(document.rebateCalc.hotWaterE.checked == true) { total += parseFloat(document.rebateCalc.hotWaterE.value); }
    
    
    var ts = new String(total);
        if(ts.indexOf('.') < 0) { ts += '.00'; }
        if(ts.indexOf('.') == (ts.length - 2)) { ts += '0'; }
        document.rebateCalc.T.value = ts;
    }
    Chris Blackwell - my blog and ramblings
    Comicville - Daily News and Comic Reviews

    "web development is what I love...so that's what I do"


  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Before your "var ts =...." stuff

    Code:
    if (total > 10000) { total = 10000; }

  3. #3
    SitePoint Guru XraySierra's Avatar
    Join Date
    Jan 2002
    Location
    Ontario, Canada
    Posts
    850
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Worked great, thank you
    Chris Blackwell - my blog and ramblings
    Comicville - Daily News and Comic Reviews

    "web development is what I love...so that's what I do"



Bookmarks

Posting Permissions

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