Dividing a number, then display result in form field

The form I’d like to modify populates this field (balance amount) upon the page appearing:

<div class="col-md-10">
<input type="text" readonly="true" class="form-control input-md" type="number" placeholder="00" value="{{balance}}">  

I’d like to divide that balance amount by 2, and have that result display it’s own seperate form field.
Any help with this is appreciated.

The following will work:

<input id="source-field" type"number">
<input id="target-field" type="number" readonly="true">

const sourceField = document.querySelector('#source-field');

sourceField.addEventListener('keyup', (event) => {
  const userNumber = event.target.value;
  const changeField = document.querySelector('#target-field');

  changeField.value = userNumber / 2;

When you change the source field, the target field will update.

Sponsor our Newsletter | Privacy Policy | Terms of Service