Results 1 to 2 of 2

Thread: help

  1. #1
    Join Date
    Mar 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help

    im a beginner. i have this program but the answer says "undefined" what's wrong?


    <HTML>
    <HEAD>
    <TITLE> BAD CREDIT </TITLE>
    <SCRIPT type="text/javascript">
    function monthlyRate () {
    var price =
    parseFloat(document.getElementById("price").value);
    var interest =
    parseFloat(document.getElementById("interest").value);
    var pay=
    parseFloat(document.getElementById("pay").value);
    if (isNaN(price) || isNaN(interest) || isNaN(pay)) {
    return;
    }


    price.toFixed(2)
    var interest = "+ interest +" ;
    var monthrate = interest / 100 ;
    monthrate = monthrate + 1 ;
    monthrate = ((Math.pow(1 + interest , 1/12)) - 1);

    var monthly = monthrate;
    var bill = "+ price +" ;
    var month = 0;
    var pay = "+ pay +" ;


    while ( bill >= pay ) {
    bill = price - pay ;
    bill = bill * (1 + monthly);
    price = bill ;

    }
    if ( bill < pay ) {
    var totalamount = pay * month + bill ;

    }

    document.getElementById("amount").value = totalamount;


    }


    </SCRIPT>
    </HEAD>
    <BODY>
    Enter the purchase price for the item you are interested in buying: <input onchange=monthlyRate() size=13 type=text id=price /><br/>
    Enter the annual interest rate on your credit card: <input onchange=monthlyRate() size=13 type=text id=interest /><br/>
    Enter the amount of money you plan to pay towards you credit card balance each month: <input onchange=monthlyRate() size=13 type=text id=pay /><br/>
    The amount you actually spent is: <input size=5 type=text id=amount /><br/>

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Some variables that you've used in computation seems to be of String type and that creates the issues.

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
  •