Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda