Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
Javascript dynamic name to php

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,

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda