0

With every purchase, the items should reduce in quantity from the bincard table.
My code is not working. What is the solution for this.

<button type="submit" name="btnSubmit" onclick="reduce();" class="btn btn-success">
    <i class="fa fa-print"></i>Print
</button>

<script type="text/javascript">

    function reduce() 
    {                                                   
        var rows = document.getElementById("TableA")
                           .getElementsByTagName("tbody"[0]
                           .getElementsByTagName("tr").length;
        for(var x=0; x<rows; x++)
        {
            var id = document.getElementById("TableA")
                             .getElementsByTagName("tbody")[0]
                             .getElementsByTagName("tr")[x]
                             .getElementsByTagName("td")[4]
                             .innerHTML;
            var qu = document.getElementById("TableA")
                             .getElementsByTagName("tbody")[0]
                             .getElementsByTagName("tr")[x]
                             .getElementsByTagName("td")[5]
                             .innerHTML;
            var update_qu = "update bincard set QtyBalance='$qu' where BinId='$id'";

        }
        var run_qu = mysqli_query($con, $update_qu);
    }

</script>
SherylHohman
  • 16,580
  • 17
  • 88
  • 94
  • 3
    `mysqli_query` is a php method, not a javascript method. You seem to be attempting to mix server and client languages. – Matt Clark Feb 04 '18 at 07:39
  • You have javascript errors in your page, because you're trying to use PHP function in javascript code. You have to use the browser's inspector (F12) to see errors (`mysqli_query is not defined`...) – Syscall Feb 04 '18 at 07:39
  • You should be sending the new values to a php page where it can be handled in the backend, this is a massive security flaw along with being wrong. – Jude Fernandes Feb 04 '18 at 07:41
  • 1
    Possible duplicate of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – Rotimi Feb 04 '18 at 07:46

0 Answers0