/    Sign up×
Community /Pin to ProfileBookmark

Javascript Won’t Run (updated)

<!DOCTYPE html>
<html>
<head>
<title>Goal Calculator</title>
<link rel=”stylesheet” href=”styles.css”>
<script>
function calculate() {
sbal = sbal.toNumber()
goal = goal.toNumber()
exp = exp.toNumber()
accben = accben.toNumber()
var sbal = document.getElementById(‘sbal’).value;
var goal = document.getElementById(‘goal’).value;
var exp = document.getElementById(‘exp’).value;
var accben = document.getElementById(‘accben’).value;
var main = ((goal – (sbal – accben)) / 12 );
var payment = (main + exp).toFixed(2);
document.getElementById(‘payment’).innerHTML = “Weekly Savings = $”+payment;
}

</script>

</head>
<body>
<div class=”wrapper”>
<div class=”contact-form”>
<div class=”input-fields” id=”calculate-form”>
<div class=”drop”>
<label>Time Period</label>
<select id = “myList”>
<option value = “1”>Week</option>
<option value = “2”>Fortnight</option>
<option value = “3”>Year</option>
</select>
</div>
<input id=”sbal” class=”input” type=”number” placeholder=”Starting Balance”>
<input id=”goal” class=”input” type=”number” placeholder=”Overall Goal”>
<input id=”exp” class=”input” type=”number” placeholder=”Expenditure”>
<input id=”accben” class=”input” type=”number” placeholder=”Account Benchmark”>
<h2 id=”payment”></h2>
</div>
</div>
</div>
</div>
<div>
<button class=”btn” id=”footer” onclick=”calculate()”>Submit</button>
</div>
</body>
</html>

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@VITSUSADec 30.2019 — What do you want to implement?
Copy linkTweet thisAlerts:
@T1AlphaauthorDec 31.2019 — @VITSUSA#1612334

I would like the var Payment to output into the h2 tags but nothing seems to be working. Any suggestions would be greatly appreciated
Copy linkTweet thisAlerts:
@ib_mintDec 31.2019 — Try this code:

``<i>
</i>function calculate() {
var sbal = parseInt(document.getElementById('sbal').value);
var goal = parseInt(document.getElementById('goal').value);
var exp = parseInt(document.getElementById('exp').value);
var accben = parseInt(document.getElementById('accben').value);
var main = ((goal - (sbal - accben)) / 12 );
var payment = (main + exp).toFixed(2);
document.getElementById('payment').innerHTML = "Weekly Savings = $" + payment;
} <i>
</i>
``
Copy linkTweet thisAlerts:
@T1AlphaauthorJan 11.2020 — @ib_mint#1612379 You are an honest god, cheers legend!
×

Success!

Help @T1Alpha spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...