Help! Hook Up the Buttons


Hi guys.

The instruction is this:

"Add onclick attributes to both of the buttons, calling the modify_qty() function."

See the html and JavaScript code below

<script type="text/javascript" src="script.js"></script>
<label for="qty">Quantity</label>
<input id="qty" value="0" />

function modify_qty(val) {
    var qty = document.getElementById('qty').value;
    var new_qty = qty + val;
    if (new_qty < 0) {
        new_qty = 0;
    document.getElementById('qty').value = new_qty;
    return new_qty;




This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.