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

172
Views
Dynamic onclick event fileupload event

I want to add a dynamic onclick event on each file upload so that I can remove files at a particular index.

Multiple file upload working perfectly fine but now I want to remove particular file at specific index.

window.onload = () => {

    uploadedfiles = function () {
        var input = document.getElementById('files');
        var children = "";
        for (var i = 0; i < input.files.length; ++i) {
            var click = removeFile(i);
            children += '<li data-index="' + (i) + '"> <a onclick="' + click +'" href="javascript:void(0)">' + input.files.item(i).name + '</a><i class="fas fa-times-circle delete" id="' + input.files.item(i).name + '"></i></li>';
        }
        $("#fileslist").html(children);
    }

    removeFile = function (i) {
        console.log(i);
    }

}

Currently unable to add removeFile() function dynamically. It becomes undefined in the loop.

Can anybody tell me what's wrong going on here?

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!