View Full Version : Converting Objects to Intergers

07-17-2007, 07:50 PM
//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.




<!-- 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 -->


<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>
<td colspan=4 align=center><input type=reset></td></tr>






07-18-2007, 04:17 PM
Nevermind, I figured it out:
Had to convert with following line:

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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum