459,466 Members | 1,148 Online
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

# How do you write a formula and use variables in javascript/html?

 P: 2 What I am looking to do is create a group of variables that work off each other and I'm not sure how to do this. I'm looking to create a webpage that compounds interest quarterly and am not sure how I would go about implementing the code and variables. I believe I have the page lain out but am not sure how to go about making the variables change with each quarter. So I can get quarter one complete, but have no idea how to write the formulas or code that work off the first quarter to complete the second quarter. Here is my haphazard attempt and what I have done so far. Any help is greatly appreciated. Expand|Select|Wrap|Line Numbers         quarterly interest

Quarterly Interest Calculator

Beginning Balance:\$
Interest Rate:%

 P: 2 I'm starting to get a bit closer to what I need to have but still feel lost. I will post my progress. I am still lost as to what I need to do with the variables to make this work. ANY help would be greatly appreciated at this point. I will continue to edit this as I go. Expand|Select|Wrap|Line Numbers           quarterly interest

Quarterly Interest Calculator

Beginning Balance:\$
Interest Rate:%
QuarterPrincipalInterest Earned
1\$ 10,000 \$ 350
2\$ 10,350\$ 362.25
3\$ 10712.25\$ 374.928
4\$ 11087.18\$ 388.05

Q1=document.getElementById('amountBox').value;           interest=document.getElementById('interestBox').value)/100;           Qa=Q1*interest;           Qb=Q2*interest;           Qc=Q3*interest;               Q2=Q1+Qa;           Q3=Q2+Qb;           Q4=Q3+Qc;"
Sep 26 '11 #2