Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve "identifier starts immediately after numeric literal"

I have tried for following code in javascript, but I get:

identifier starts immediately after numeric literal 

error is coming for following script, example mcnDel="016160A1"

<script>
 mcnDel="016160A1"               
 var val="<a href='javascript: void(0);' onclick='removeRow("+mcnDel+");'><img src=images/delete.png></a></a></td>"  
</script>
like image 559
chaya Avatar asked Aug 26 '14 15:08

chaya


3 Answers

You need to wrap the string with quotes.

onclick='removeRow("+mcnDel+");'

needs to be

onclick='removeRow(\""+mcnDel+"\");'
like image 193
epascarello Avatar answered Nov 01 '22 06:11

epascarello


FYI, I got that error while trying to use BigInt() and big integer litterals (e.g. 123n on Safari for iOS.

like image 3
Adrien Joly Avatar answered Nov 01 '22 08:11

Adrien Joly


Dont forget Javascript id cannot start with a number, make sure the value of your variable is not starting with a number.

like image 1
Amir Avatar answered Nov 01 '22 07:11

Amir