Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
How to keep track of a purchase total based on number of clicks

I am trying to keep track of a running total based on number of clicks on the buttons on the site. There are 8 buttons, all of which should add $123.45 to the total when clicked, as well as alert the total.

Some of my HTML

<article class="dog-card">
  <img src="images/murphy-card.jpg" alt="a brown and white dog with a questioning look on his face" onclick="dogInfo('Murphy', 'Mix', '$123.45')">
  <h3>Murphy</h3>
  <p><strong>Cost to Adopt:</strong> $123.45</p>
  <p>Corrum volorit iandae nimaxim cum restia volor reicid ut et etur sunt arum rendae pla endis re ea erum, qui doluptae</p>
  <p class="adopt" onclick="addFee()">Adopt</p>
</article>

And my JS so far

function addFee() {
  let x = 123.45;
  let total = ('Your total is $' + x);

  alert(total);
}

I know this JS isn't what I need, but I just wanted to put something in so I could verify the button was working.

Any advice is much appreciated, thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

let LastTotal = 0;

function addFee() {
  lastTotal = lastTotal + 123.45;
  alert("Your total is $" + lastTotal);
}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!