Changing values in column in table using buttons

i would like create a table, where one column would be variables and i want to have “+” and “-” buttons next to it. So when i click button “+” it would show number input and after submit, it would add to the value.
It works for one value, but do not get the other right, without copying whole script.


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Table</title>
</head>
<style>
    body {
        background-color: lightslategray;
    }
    #PLA {
        float: left;
        width: 30%;
        padding: 10px;
    }
    th, td {
        border: 1px solid;
    }
    .header {
        text-align: center;
        font-size: 20px;
    }
    .celltext {
        font-size: 15px;
    }
    .number {
        text-align: center;
    }
    .vbutton {
        background-color: gray;
        border: 1px solid black;
        border-radius: 6px;
        color: white;
        text-align: center;
        text-decoration: none;
        font-size: 10px;
        padding: 0px;
        margin-right: 4px;
        width: 20px;
        height: 20px;
        float: right;        
    }
    button:hover {
        background-color: lightgray;
        color: black;
    }
    .input {
        padding: 0px;
        width: 48px;
        height: 16px;
        font-size: 14px;
        -webkit-appearance: none;
    }
    input[type = number] {
        -moz-appearance: textfield;
    }  
    input:focus {
        border: 0px;
        outline: 0px;
    } 
</style>
<body>
    <table id="PLA">
        <div>
            PLA
            <span id="test"></span>
            <input type="number" class="input" id="nwpla" onchange="changewpla1()" onkeypress="return onlyNumberKey(event)">
        </div>
        <tr class="header">
            <td>Barva</td>
            <td>Výrobce</td>
            <td>Hmotnost (g)</td>
            <td>Cena (kg)</td>
        </tr>
        <tr class="celltext">
            <td>černá <div class="box black"></div></td>
            <td>Polymaker PolyLite</td>
            <td class="number" id="pla1">
                <span id="wpla1"></span> 
                <button class="vbutton" onclick="addpla()"> + </button>  
                <button class="vbutton" onclick="subpla()"> - </button>  
            </td>
            <td class="number"> 
                800  
            </td>
        </tr>
        <tr class="celltext">
            <td>černá <div class="box black"></div></td>
            <td>Polymaker PolyLite</td>
            <td class="number" id="pla2">
                <span id="wpla2"></span> 
                <button class="vbutton" onclick="addpla()"> + </button>
                <button class="vbutton" onclick="subpla()"> - </button>  
            </td>
            <td class="number"> 
                800  
            </td>
        </tr>
    </table>
</body>
<script>
    // test
    test = document.getElementById("test");

    // Weight of pla1
    wpla1 = document.getElementById("wpla1");
    nwpla = document.getElementById("nwpla");
    nwpla.style.display = "none"; 
    var pla1weight = localStorage.pla1weight;
    localStorage.setItem("pla1weight", pla1weight); 

    if (localStorage.pla1weight == "undefined" || localStorage.pla1weight == isNaN) {
        localStorage.pla1weight = 0
        pla1weight = 0;
        wpla1.innerHTML = localStorage.pla1weight;
        wpla1.value = localStorage.pla1weight;
    }
    else {
        wpla1.innerHTML = localStorage.pla1weight;
        wpla1.value = localStorage.pla1weight;
    } 
    function changewpla1() {
        x = parseInt(wpla1.value, 10); 
        y = parseInt(nwpla.value, 10);       
        if (p == 1) {
            pla1weight = x - y; 
        } else {
            pla1weight = x + y;
        }            
        wpla1.innerHTML = pla1weight;
        wpla1.value = pla1weight;
        localStorage.setItem("pla1weight", pla1weight); 
        nwpla.style.display = "none";       
    }

    // Weight of pla2
    wpla2 = document.getElementById("wpla2");
    nwpla = document.getElementById("nwpla");
    nwpla.style.display = "none"; 
    var pla2weight = localStorage.pla2weight;
    localStorage.setItem("pla2weight", pla2weight); 

    if (localStorage.pla2weight == "undefined" || localStorage.pla2weight == isNaN) {
        localStorage.pla2weight = 0
        pla2weight = 0;
        wpla2.innerHTML = localStorage.pla2weight;
        wpla2.value = localStorage.pla2weight;
    }
    else {
        wpla2.innerHTML = localStorage.pla2weight;
        wpla2.value = localStorage.pla2weight;
    } 
    function changewpla2() {
        x = parseInt(wpla2.value, 10); 
        y = parseInt(nwpla.value, 10);       
        if (p == 1) {
            pla2weight = x - y; 
        } else {
            pla2weight = x + y;
        }            
        wpla2.innerHTML = pla2weight;
        wpla2.value = pla2weight;
        localStorage.setItem("pla2weight", pla2weight); 
        nwpla.style.display = "none";       
    }


    function addpla() {
        nwpla.value = 0;    
        p = 0;    
        nwpla.style.display = "";
    }
    function subpla() {
        nwpla.value = 0
        p = 1;
        nwpla.style.display = "";
    }
    function onlyNumberKey(evt) {
        var ASCIICode = (evt.which) ? evt.which : evt.keyCode
        if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57))
            return false;
        return true;
    }

</script>
</html>

Any idea?
I would like to have a database as last option. Every value would be saved in local storage.

Thanks.