简体   繁体   中英

Change other input field value by changing Increment/decrement value jQuery

i have a increment decrement input field and i want to change value of other input text field by by plus and minus value. let suppose if value is selected from increment decrement input field then the other text field value appears 100 and if value select 2 then other field value appears 200 and so on. so far i just create a increment decrement field. don't know how to do next. please help me on this problem and forgive me about this because i'm and still learning.

this is just simple plus/minus input field

I've altered your JSFiddle to help you out here. You simply needed to add a new method to calculate the new value (100 * count) and assign that value to the appropriate input box, and then call that method from your plus and minus methods.

https://jsfiddle.net/jebcnvwd/

var count = 1;
var countEl = document.getElementById("count");

function plus() {
  count++;
  countEl.value = count;
  calculateResult(count);
}

function minus() {
  if (count > 1) {
    count--;
    countEl.value = count;
    calculateResult(count);
  }
}

function calculateResult(count) {
  var resultInt = count * 100;
  var resultInput = document.getElementById("result");
  resultInput.value = resultInt;
}

calculateResult(count);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM