Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Uncaught error : Invalid or unexpected Token

AgrebiAlaa
Kilo Explorer

this code in client script give me this error ' uncaught error : invalid or unexpected token ' 

this is the line of code :   document.getElementsByName(id)[0].innerHTML+='<button class="btn btn-default btn-sm" id='+element.files[i].name+' onclick="removeFiles('+id+',this.id)">'+ element.files[i].name + element.files[i].size+'KB <i class="fas fa-trash-alt"></i>  '+'</button>'+' .</br>'+''; 

any solutions ? Thanks .

4 REPLIES 4

hvrdhn88
Giga Patron

can you check the function parameter you have used in onClick, is that correct  ?

 

onclick="removeFiles(id,this.id)"  // try to change the parameter you have passed . 

this is the function removeFiles : 2 parameters id and file name 

removeFiles = function(id,fname) {
console.log('removing '+fname);
document.getElementById(fname).remove();
activity_attch.forEach(function(item){
if(item.id == id ){
for(var i=0;i<item.list;i++){
if(f.name==fname){
item.list.splice(i,1);
}

}
}
});

}

can you try to pass the parameter as i had mentioned in onclick . and see if it's giving you an error ? 

that mean i pass id and this.id in the definiton of function removeFiles?