I am trying to execute a Javascript function when an input changes its value. The input changes its value when other inputs are clicked (those inputs increase or decrease the value).
Here is my html code:
<input type='button' value='–' class='qtyminus' field='quantity{{$accessory-
>id}}' style="font-weight: bold;" />
<input id='accessory{{$i}}' onchange="updateNoAccessories({{$i}})"
type='text' name='quantity{{$accessory->id}}' value='1'
class='qty' style="margin-bottom: 0px !important"/>
<input type='button' value='+' class='qtyplus' field='quantity{{$accessory-
>id}}' style="font-weight: bold;" />
JS function:
function updateNoAccessories(i) {
var no = document.getElementById("accessory"+i).value;
document.getElementById("acc"+i).innerHTML = no + ' x';
}
What I want to update from JS function:
<span>You chose:<i><b id="acc0"></b> items,</i><i><b id="acc1"></b>
things,</i><i><b id="acc2"></b>stuff</i></span>