<input id="elem1" type="number" name="quantity" placeholder="Количество">
<button>click</button>
<div id="str"></div>
document.querySelector('button').onclick = function () {
let input = document.getElementById('elem1').value;
for (i = 0; input.length < 0; i--) {
document.getElementById('str').innerHTML = "Вы ввели: " + input;
}
};
document.querySelector('button').addEventListener('click', function() {
const val = +document.querySelector('#elem1').value;
const sign = Math.sign(val);
document.querySelector('#str').innerHTML = Array
.from({ length: val * sign + 1 }, (n, i) => val - i * sign)
.join('<br>');
});