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
Can't set button's onclick callback to a function in a string

I'm making an app that lets users upload stuff. I am trying to set the onclick callback of an upload button to a function by doing this inside one of my classes:

this.uploadMusicButton.onclick = "upload('music' + this.frameNum)"; 

// ^ this code is inside of a custom class
// the code below is outside of any js class

function upload(purpose)
{
  alert("made it here");
  uploadPurpose = purpose;                 
  document.getElementById("openFile").click();
}

But when I try clicking the button, nothing happens. Can someone please help me?

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!