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

268
Views
How to add a value number when press the button?

How to add number value when i click button? For example If i click 100,000 twice, 200,000 will be entered in the input.

$(document).ready(function() {
  $('#myform button').on('click', function() {
    $('#cvalue').val($(this).val());
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>


<div class="box">
  <form id="myform">
    <div class="inputdiv">
      <input type="text" id="cvalue" class="money">
    </div>
    <button class="button1" type="button" value="100,000">100,000</button>
    <button class="button1" type="button" value="200,000">200,000</button>
    <button class="button1" type="button" value="300,000">300,000</button>
    <button class="button1" type="button" value="500,000">500,000</button>
    <button class="button1" type="button" value="1,000,000">1,000,000</button>
  </form>

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

0

Not trivial

const fmt = new Intl.NumberFormat('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 0 });

$(document).ready(function() {
  const $cvalue = $('#cvalue');
  $('#myform .button1').on('click', function() {
    const val = +$(this).val().replace(/\D/g, "") + +$cvalue.val().replace(/\D/g, "")
    $cvalue.val(fmt.format(val));
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>


<div class="box">
  <form id="myform">
    <div class="inputdiv">
      <input type="text" id="cvalue" class="money" value="0">
    </div>
    <button class="button1" type="button" value="100,000">100,000</button>
    <button class="button1" type="button" value="200,000">200,000</button>
    <button class="button1" type="button" value="300,000">300,000</button>
    <button class="button1" type="button" value="500,000">500,000</button>
    <button class="button1" type="button" value="1,000,000">1,000,000</button>
  </form>

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!