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

132
Visualizações
Submit Multiple Checkboxes Data

I am making a WooCommerce/Wordpress Website for someone wanting to start a meal prep service. She wants it to be similar to a create your own pizza script, except it will be used to customize meals. There will be checkboxes that display ingredients, and if the boxes are checked, I need to submit them so that the website owner knows what meals to make.

Example:

Email Form

Meats: Checkbox1 : Steak

Checkbox2 : Chicken

Checkbox3 : Pork

This is an example of what I have so far:

<div>
   <input type="checkbox" name="foodType" data-name="Chicken Thighs"> 
   <label>Chicken Thighs</label>
   <input type="checkbox" name="foodType" data-name="Chicken Breast"> 
   <label>Chicken Breast</label>
   <input type="checkbox" name="foodType" data-name="Chicken Leg"><label>Chicken Leg</label>
   
   </div>

   <div id='results'>
   </div>

var finalOrder = [];

document.querySelectorAll('input[name=foodType]').forEach(elem => {
elem.addEventListener('change', updateList);
});

function updateList ()
{
finalOrder = []; // Reset this array so that we can populate it with 
the new checkbox answers.

document.querySelectorAll('input[name=foodType]').forEach(v => {
if (v.checked) {
finalOrder.push(v.dataset.name);
}
});

document.querySelector('#results').innerHTML = buildList();
}


function buildList ()
{
let list = '<ul>';

finalOrder.forEach(str => {
list += "<li>" + str + '</li>';
});

list += '</ul>';

return list;
}

I am very new to Javascript so I had a little help, but I need to make sure that she gets the checkbox data. Am I going about this correctly? I was going to append the checkbox data to an array and send the array to her somehow. How would you recommend going about doing that?

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