const input = document.querySelector('.inputprice');
const container = document.querySelector('.inner');
const itemSelector = '.box';
const buttonSelector = `${itemSelector} .btn`;
const valueSelector = `${itemSelector} .box-title`;
container.addEventListener('click', ({ target: t }) => {
const item = t.closest(buttonSelector)?.closest(itemSelector);
if (item) {
input.value = item.querySelector(valueSelector).innerText;
}
});
// или
const onClick = el => input.value = el.textContent.trim();
container.querySelectorAll(buttonSelector).forEach(function(n, i) {
n.addEventListener('click', onClick.bind(null, this[i]));
}, document.querySelectorAll(valueSelector));