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

92
Views
Is there a reason my input isn't showing up?

Working on a budget application. I'm trying to get the number I'm inputting to be redirected to a p tag, but it's not showing up. I tested my code and I was able to get the text (Your Balance) to show up just fine, but the actual number that I'm taking from my input isn't showing up at all. I've tried a few things but can't seem to figure out why. Is it just not turning my input into a number?

html

<div class="enter-budget">
            <label for="budget">Please Enter Your Budget</label>
            <input type="number" id="input-balance">
            <button onclick="addBalance()">Calculate</button>
        </div>

            <div class="budget">
                <p>Budget</p>
                <p id="budget-amount"></p>
            </div>

javascript

let budget = document.getElementById("budget-amount");
let inputBalance = document.getElementById("input-balance").value;

const addBalance = () => {
    budget.textContent = `Your Balance: ${inputBalance}`
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are getting a reference to the input value immediately, instead of when the addBalance method is called. You need to get the value when it's called.

let budget = document.getElementById("budget-amount");
let inputBalance = document.getElementById("input-balance");

const addBalance = () => {
  let balance = inputBalance.value;
  budget.textContent = `Your Balance: ${balance}`
}
<div class="enter-budget">
  <label for="budget">Please Enter Your Budget</label>
  <input type="number" id="input-balance">
  <button onclick="addBalance()">Calculate</button>
</div>

<div class="budget">
  <p>Budget</p>
  <p id="budget-amount"></p>
</div>

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!