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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Converting Objects to Intergers

    //I need to add fom.years.value to form.Months.value. I know you can't add objects, so how do i convert them to intergers, so I can add them. Formula is (Years*12) + Months = Total Months.

    Thanks,
    Wally

    <HEAD>


    <SCRIPT LANGUAGE="JavaScript">


    <!-- Begin
    function compute(form) {
    var totaltime= (form.Years.value +(form.Months.value/12))
    var factor=((totaltime*12)/(form.Term.value))
    form.Effective_Interest_Rate.value = ((factor) *(form.Note_Rate.value*.1))
    }
    // End -->
    </script>
    </HEAD>



    <BODY>

    <center>
    <form>
    <table border=3>
    <tr><td>Years: </td><td><input type=text name=Years size=2></td></tr>
    <tr><td>Months: </td><td><input type=text name=Months size=1> </td></tr>
    <tr><td>Term of Loan: </td><td><input type=text name=Term size=3> </td></tr>
    <tr><td>Note_Rate: </td><td><input type=text name=Note_Rate size=6>%</td></tr>

    <tr><td colspan=4 align=center><input type=button value="Calculates To...." onClick="compute(this.form)"></td></tr>
    <tr><td><input type=text name=Effective_Interest_Rate size=12></td><td>% Effective Rate</td></tr>
    <tr>
    <td colspan=4 align=center><input type=reset></td></tr>
    </table>
    </form>
    </center>

    <p><center>

    </center><p>

    </div>

    </body>

    </html>

  • #2
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind, I figured it out:
    Had to convert with following line:


    varName=parseInt(formName.ElementName.value, 10);


  •  

    Posting Permissions

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