Uncaught error : Invalid or unexpected Token
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 12:56 AM
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 .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 01:44 AM
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 01:55 AM
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);
}
}
}
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 02:02 AM
can you try to pass the parameter as i had mentioned in onclick . and see if it's giving you an error ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 02:18 AM
that mean i pass id and this.id in the definiton of function removeFiles?