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

Join 86,383 Programmers. There are 1,373 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!

Investment Loop

 
Reply to this topicStart new topic

Investment Loop, Loop Structure

Randall
post 8 May, 2008 - 02:59 AM
Post #1


New D.I.C Head

*
Joined: 26 Mar, 2008
Posts: 6



Hi Guys, im making a investment loop where you enter a initial deposit say $100,plus a annual intrest rate say 12% and a target amount that the user wishes to reach say $200 then calculate those amounts to display the exact month/months it will take to reach the target.

here is my code:

CODE
<script type="text/javascript">

function calculate() {
initialdeposit = parseInt (document.input.initialdeposit.value)
annualrate = parseInt (document.input.annualrate.value)
targetsavings = parseInt (document.input.targetsavings.value)
monthlyrate = (annualrate / 12) / 100



do {
answer =  initialdeposit * monthlyrate
} while (answer == targetsavings)

document.output.result.value = answer
}

</script>
</head>



<h1>Investment</h1>

<form name="input">

Please enter your initial deposit:
<input type="text" name="initialdeposit">
<br />
Please enter your annual interest rate:
<input type="text" name="annualrate">
<br />
Please enter your target savings amount:
<input type="text" name="targetsavings">
<br />
<input type="button" value="Calculate" onClick="calculate()">
</form>

<form name="output">
It will take
<input type="text" name="result">month/s to reach your target amount.
</form>
</body>

</html>


hope you guys can help me or eplain what i need to do to get it to work.

Cheers Randall.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


BenignDesign
post 8 May, 2008 - 04:01 AM
Post #2


D.I.C Regular

Group Icon
Joined: 28 Sep, 2007
Posts: 485

Is it currently functioning at all? If so, at what point does it stop functioning?

Just a quick glance - and I don't know if you simply did not include all the code - but you are missing your opening html and head tags.

This post has been edited by BenignDesign: 8 May, 2008 - 04:02 AM
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 03:48AM

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