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

161
Visualizações
Image checkbox 'uncaught' html & javascript

I have these images (self-made 'emoj's') overlayed on checkboxes so when you click one of them, you'll be taken to the next page where you can click another one. Then you`re taken to the results-page where a function runs with this idea:

if (emoji1Page1.checked && emoji2Page2.checked){
  fetchApiDataEmoji1AndEmoji();
}

Emoji1 is a comic jesus drawing and emoji2 here is a timebomb drawing (this info makes it a bit more clear)

So we get this html and I'm trying to get the if statement going with this

I inserted the test to see if the images are caught but nothing, only this error

'Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')'

Any any ideas how to get this down? Thanks!

const contentEmojiChecked = document.getElementById('jesus');
const hasteChecked = document.getElementById('timebomb');

contentEmojiChecked.addEventListener('click', test);

function test(e) {
  e.preventDefault();
  console.log('test');
}

hasteChecked.addEventListener('click', test);

function test(e) {
  e.preventDefault();
  console.log('test');
}

if (contentEmojiChecked && hasteChecked) {
  getRecipesForContentEmojiAndHaste()
}
<label for="jesus">
  <a href="secondQuestion.html" >
    <img src="../../assets/Jezus button.png" class="jesus" />
    <input type="checkbox" id="jesus"/>
  </a>
</label>

<label for="timebomb">
  <a href="result.html" >
    <img src="../../assets/tijdbom.png" class="timebomb"/>
    <input type="checkbox" id="timebomb"/>
  </a>
</label>

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