so i have this variable
$number = "1944/UN31/KEP/2017"
then i want to replace the "/"
to ""
so i create new variable:
$number2 = str_replace("/","",$number) // the result would be : 1944UN31KEP2017
i can access my $number variable to js before using (in laravel blade):
onClick="doPrintTxtdaftar({{ $number}});">Print</a>
but when i replaced the string and the 2nd variable :
onClick="doPrintTxtdaftar({{ $number2}});">Print</a>
i got an error in my debuger saying : SyntaxError: identifier starts immediately after numeric literal
and its pointing out my 2nd varable value : 1944UN31KEP2017
can somebody pls help me… Thanks
Advertisement
Answer
Wrap with quotes
Change this:
onClick="doPrintTxtdaftar( {{$number}} )">Print</a>
to:
onClick="doPrintTxtdaftar( '{{$number}}' )">Print</a>
Hope this work for you !!!