Jump to content

hvumonsen@hotmail.com

Members
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

hvumonsen@hotmail.com's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi!We are some students at Oslo University College who got this assignment to make a JavaScript that switch the contents in a dropdown list. The highlighted word in the left dropdown list is supposed to copy into the right whitout disappearing from the left, than move down to the bottomn of the left list. The secound word transferred to the right dropdown list is supposed to appear on top of the list. Hope you got this...take a look: http://members.lycos.co.uk/rlarsen/meny.html
  2. I am an student at the Norwegian Oslo University Collage where I study Computer Science.I have a project in Javascript where I'm goint to make a Loan Calculator...I did, but it did not work. Why? what's wrong? <HTML> <HEAD> <TITLE>Loan Calculator</TITLE> <script LANGUAGE="JavaScript"> <!-- hide from non-JavaScript browsers function roundToPennies(n) { pennies = n * 100; pennies = Math.round(pennies); strPennies = new String(pennies); len = strPennies.length; return strPennies.substring(0, len — 2) + "." + _strPennies.substring(len — 2, len); } function Monthly(principal, years, apr) { rate = apr / 12; payments = years * 12; return roundToPennies(principal * rate / (1 — (1 / Math.pow(1 + _rate, payments)))); } function MonthlyAmortization(principal, years, apr) { payments = years * 12; monthlyInterest = apr / 12; monthlyPayment = Monthly(principal, years, apr); document.write("<CENTER>"); document.write("<H1>Amortization Table</H1>"); document.write("<HR>"); document.write("<TABLE BORDER>"); document.write("<TR>"); document.write("<TH COLSPAN=4>"); document.write("$" + roundToPennies(principal)); document.write(" at " + roundToPennies(apr*100) + "%"); document.write(" over " + years + " years.<BR>"); document.write("Monthly payment: $" + Monthly(principal, years, apr)); document.write("</TH>"); document.write("</TR>"); document.write("<TR>"); document.write("</TH>"); document.write("<TH COLSPAN=2>Payment</TH>"); document.write("</TR>"); document.write("<TR>"); document.write("Month</TH>"); document.write("Interest</TH>"); document.write("Principal</TH>"); document.write("Balance</TH>"); document.write("</TR>"); for(i = 1; i <= payments; i++) { document.write("<TR>"); document.write("<TD>" + i + "</TD>"); interestPayment = principal * monthlyInterest; document.write("<TD>$" + roundToPennies(interestPayment) + _"</TD>"); principalPayment = monthlyPayment - interestPayment; document.write("<TD>$" + roundToPennies(principalPayment) + _"</TD>"); principal -= principalPayment; document.write("<TD>$" + roundToPennies(principal) + "</TD>"); document.write("</TD>"); } document.write("</TABLE>"); document.write("</CENTER>"); } function compute(form) { if((form.principal.value.length != 0) && (form.apr.value.length != 0) && (form.years.value.length != 0)) { principal = eval(form.principal.value); apr = eval(form.apr.value) / 100.0; years = eval(form.years.value); if(years == 0.0) { alert( "You have no monthly payment, since the number of years is zero."); } else { MonthlyAmortization(principal, years, apr); } } else { alert("You must fill in all the fields."); } } //--> </SCRIPT> </HEAD> <BODY> <CENTER><H1>Loan Calculator</H1></CENTER> <HR> <CENTER> <FORM> <CENTER> Fill in the fields, then click <INPUT TYPE=BUTTON VALUE="Amortize!" onClick=compute(this.form)> </CENTER> <P> <TABLE BORDER=3> <TR> <TD>Amount of the loan ($)</TD> <TD><INPUT TYPE=TEXT NAME=principal></TD> </TR> <TR> <TD>Annual interest rate (%)</TD> <TD><INPUT TYPE=TEXT NAME=apr></TD> </TR> <TR> <TD>Total number of years</TD> <TD><INPUT TYPE=TEXT NAME=years></TD> </TR> </TABLE> </FORM> </CENTER> </BODY> </HTML>
×
×
  • Create New...