Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,374 Programmers. There are 1,412 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

loop form

 
Reply to this topicStart new topic

loop form

thatdragondude
post 7 May, 2008 - 05:45 AM
Post #1


New D.I.C Head

*
Joined: 7 May, 2008
Posts: 2



Hey lads.



i need to create a investment form that allows the user to enter;
- a cash deposit ( e.g. $5)
- an annual interest rate (e.g. 10%)
- a target savings amount (e.g. $20)

This is my code so far.. where am i going wrong?

CODE
<script type="text/javascript">

function calc() {



var principal = 5;
var months = 0;
var intRate = .12
var factor = 1 + intRate/12;
var amount = principal;
var target = 20;

while (amount <= target) {
amount = amount * factor;
months ++;
}

document.iform.m.value= amount.toFixed(2);
alert ("At " + intRate*100 + "% compound $"+ principal + " will compound to $" + amount + " after " + months + " months" );




</script>  
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 02:51AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month