Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
onEvent inside of a loop - Javascript

I've been trying to run this loop with onEvents inside of it, but it doesn't seem to work. I can click the button and everything works, the inner while loop keeps repeating until an onEvent is triggered, but none of the onEvents get triggered when I click on them.

onEvent("startBtn", "click", function() {
  setScreen("songScreen");
  setText("songName1", "Song name: " + trackName[0]);
  setText("artistName1", "Artist name: " + artistName[0]);
  setText("pos1", "Song position: " + songPos[0]);
  setText("pop1", "Song popularity: " + songPop[0]);
  while (i < songPos.length) {
    setText("songName1", "Song name: " + trackName[i]);
    setText("artistName1", "Artist name: " + artistName[i]);
    setText("pos1", "Song position: " + songPos[i]);
    setText("pop1", "Song popularity: " + songPop[i]);
    upClick();
    downClick();

  }

});

function upClick() {
  onEvent("upImg", "click", function() {
    songLiked = true;
    console.log("test up");
    i++;
  });
}

function downClick() {
  onEvent("downImg", "click", function() {
    songLiked = false;
    console.log("test down");
    i++;
  });
}

What am i doing wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!