i've been doing a seat picker system in which you can click the chair you want and it will take that chair id and insert it into the data base, i have this code
<form method="POST" id="form">
<input type="button" value="Go to payment." name="" id="so">
<script>
async function getChairs(){
let url = "code/chairs.php";
await fetch(url)
.then(response=>response.json())
.then(data=>{
console.log();
data.forEach(chair=>{
var $refChair=$(".pos" + "" + chair.id);
$refChair.attr("src","img/chair-occupied.png");
$refChair.attr("data-bs-toggle",".popover");
$refChair.attr("title","This chair is occupied by: ");
$refChair.attr("data-bs-content", chair.name);
$refChair.attr('id','2');
new bootstrap.Popover($refChair);
});
})
}
getChairs()
</script>
<script>
cho = [];
id1 = {};
$(".chair").on("click",function (){
var chimba = $(this).attr("class");
let letter1= chimba.charAt(9);
let letter2 = chimba.charAt(10);
var amazing = letter1+letter2;
var plis = document.getElementById("so");
plis.setAttribute("name", amazing);
var some = plis.getAttribute("name");
cho.push(some);
console.log(cho);
cho.shift(some);
id1.id = amazing;
cho.push(id1);
console.log(id1);
cho.shift(id1);
//window.location.href="paymethod.php";
})
</script>
I save the id from the second script in the top div, but i don't know how to take that information to php, is there a way to take those numbers to php? keep in mind that all of this is in a .php file
I tried to use event listeners, a button to send the info to the same file, i tried to insert it into an external array,