So basically I want to be able to pass a variable from Javascript to php dynamically and without $_GET and preferably without cookies, so I tried using html DOM to change the .value of the html hidden element and then posting it but it won't recognise the value has changed.
    for(i=0;i<60; i++) {
        pen.push(<?php 
            $ii += 1;
            $sql=mysqli_query($connection, "SELECT Quantity from stockinventory where ID = '$ii'");
        while($row = $sql->fetch_assoc()) {
            echo(json_encode($row['Quantity']));
                    }
        ?>);
    }
         //fix this
    function subStock(cuanto, id) {
        pen[id] = pen[id]-1;
        document.getElementById(id).innerHTML = pen[id];
        document.getElementByName(id).value = pen[id];
    }
    function addStock(cuanto, id) {
        pen[id] = parseInt(pen[id])+1;
        document.getElementById(id).innerHTML = pen[id];
        document.getElementByName(id).value = pen[id];
    }
</script>
    $search = mysqli_query($connection, "SELECT * from stockinventory WHERE categody LIKE '%$empanada%'");
    echo("<form action='admin.php' method='POST'>
        <input type='submit' name='Juan'>");
    while($row = $search->fetch_assoc()) {
        echo("<div class='wrapper' id='wrap'>
                <div class = 'dynamo' style= background-image:url(".$row['imagee'].")>
                    <h2>".$row['Name']."</h2>
                        <div class='slider' id='slider'>
                            <p id='rat'>".$row['Description']."</p>
                            <button type='button' onClick='subStock(".$row['Quantity'].",". $i.")' id= 'jose' name= 'Alma'>-</button>
                            <a id=".$i.">".$row['Quantity']."</a>
                            <button type='button' onClick='addStock(".$row['Quantity'].",". $i.")' id= 'jose' name= 'Alma'>+</button>
                            <form method='POST' action='admin.php'>
                            <input type='hidden' id= G".$i." value = 10 name = ".$i." >
                            </form>
                        </div>
                </div>
            </div>");
        $i+=1;
    }
if(isset($_POST['Juan'])) 
{
    //for($c = 0; $c<39; $c++ ) {
    $c = 1;
    $quant = $_POST[$c];
    echo($_POST[$c]);
    $dql = mysqli_query($connection, "UPDATE stockinventory
        SET Quantity = $quant
        WHERE ID = '$c'");
}