first question here ever on stack overflow so I hope it actually helps :D I am really new to coding but tried my best doing some html work and today got into the nasty javascript. So my javascript knowledge is less than basic, i have tried for hours by myself fixing this and trying to get it done by myself googling many things and watching countless of videos but I still cant get it right. Its 1 am where I am right now and Im really trying to not jump out the window :D
So what I am trying to do here is a simple calcualator of financial returns, I have a constant of 33% return and I am trying that the person can input his desired amount to invest and calculate how much money he will get in return the simple excel math is ( 15000 / 33% ) = 45,454
I realized that I cant use percentages in javascript so I decided to create a constant which eventually will give me 33% (8.25/25)
And I am extremely stuck right now, please help!
My HTML code:
<div class="col-xl-6 mt-md-30 mt-xs-30 mt-sm-30">
<div class="card">
<div class="card-body">
<h4 class="header-title">Calculate Earnings</h4>
<div class="exhcange-rate mt-5">
<form action="#">
<div class="input-form">
<input type="text" placeholder="15,000" value="" id="amount">
<span>USD</span>
</div>
<div class="exchange-devider">In 2025:</div>
<div class="input-form">
<input type="text" placeholder="45,454" value="" class="showammount">
<span>USD</span>
</div>
<div class="exchange-btn">
<button class="calculateNow" type="calculateNow">Calculate Now</button>
</div>
</form>
</div>
</div>
</div>
</div>
> My nasty horrible javascript:
<script type="text/javascript">
const percent = (8.25/25);
var inputAmmount = document.getElementById('ammount').value;
function calculate(event) {
document.getElementById('showammount') =
inputAmmount / percent ;
}
exchange-btn.addEventListener('click', calculate);
</script>
Guys if anyone of you really is willing to help me , holy $hit i can actually order you a pizza online or something, im dying to get this done and everything i do it just really backfires on me right now. I hate coding when I get this frustrated, but I love it when things seem to work out :P damn, I might go to sleep now and hope one lovely soul will help. Anyways best regards and merry christmas!
Aucun commentaire:
Enregistrer un commentaire