I have a solution that involves (Vanilla) JavaScript, but only as a library. You habe to include it once and then all you need to do is set the appropriate source
attribute of the number inputs.
The source
attribute should be the querySelectorAll
selector of the range input you want to listen to.
It even works with selectcs. And it works with multiple listeners. And it works in the other direction: change the number input and the range input will adjust. And it will work on elements added later onto the page (check https://codepen.io/HerrSerker/pen/JzaVQg for that)
Tested in Chrome, Firefox, Edge and IE11
;(function(){_x000D_
_x000D_
function emit(target, name) {_x000D_
var event_x000D_
if (document.createEvent) {_x000D_
event = document.createEvent("HTMLEvents");_x000D_
event.initEvent(name, true, true);_x000D_
} else {_x000D_
event = document.createEventObject();_x000D_
event.eventType = name;_x000D_
}_x000D_
_x000D_
event.eventName = name;_x000D_
_x000D_
if (document.createEvent) {_x000D_
target.dispatchEvent(event);_x000D_
} else {_x000D_
target.fireEvent("on" + event.eventType, event);_x000D_
} _x000D_
}_x000D_
_x000D_
var outputsSelector = "input[type=number][source],select[source]";_x000D_
_x000D_
function onChange(e) {_x000D_
var outputs = document.querySelectorAll(outputsSelector)_x000D_
for (var index = 0; index < outputs.length; index++) {_x000D_
var item = outputs[index]_x000D_
var source = document.querySelector(item.getAttribute('source'));_x000D_
if (source) {_x000D_
if (item === e.target) {_x000D_
source.value = item.value_x000D_
emit(source, 'input')_x000D_
emit(source, 'change')_x000D_
}_x000D_
_x000D_
if (source === e.target) {_x000D_
item.value = source.value_x000D_
}_x000D_
}_x000D_
}_x000D_
}_x000D_
_x000D_
document.addEventListener('change', onChange)_x000D_
document.addEventListener('input', onChange)_x000D_
}());
_x000D_
<div id="div">_x000D_
<input name="example" type="range" max="2250000" min="-200000" value="0" step="50000">_x000D_
<input id="example-value" type="number" max="2250000" min="-200000" value="0" step="50000" source="[name=example]">_x000D_
<br>_x000D_
_x000D_
<input name="example2" type="range" max="2240000" min="-160000" value="0" step="50000">_x000D_
<input type="number" max="2240000" min="-160000" value="0" step="50000" source="[name=example2]">_x000D_
<input type="number" max="2240000" min="-160000" value="0" step="50000" source="[name=example2]">_x000D_
<br>_x000D_
_x000D_
<input name="example3" type="range" max="20" min="0" value="10" step="1">_x000D_
<select source="[name=example3]">_x000D_
<option value="0">0</option>_x000D_
<option value="1">1</option>_x000D_
<option value="2">2</option>_x000D_
<option value="3">3</option>_x000D_
<option value="4">4</option>_x000D_
<option value="5">5</option>_x000D_
<option value="6">6</option>_x000D_
<option value="7">7</option>_x000D_
<option value="8">8</option>_x000D_
<option value="9">9</option>_x000D_
<option value="10">10</option>_x000D_
<option value="11">11</option>_x000D_
<option value="12">12</option>_x000D_
<option value="13">13</option>_x000D_
<option value="14">14</option>_x000D_
<option value="15">15</option>_x000D_
<option value="16">16</option>_x000D_
<option value="17">17</option>_x000D_
<option value="18">18</option>_x000D_
<option value="19">19</option>_x000D_
<option value="20">20</option>_x000D_
</select>_x000D_
<br>_x000D_
_x000D_
</div>_x000D_
<br>
_x000D_