SyntaxError: identifier starts immediately after numeric literal, str_replace variable to javascript
SyntaxError: identifier starts immediately after numeric literal, str_replace variable to javascript
所以我有这个变量
$number = "1944/UN31/KEP/2017"
然后我想将 "/"
替换为 ""
所以我创建了新变量:
$number2 = str_replace("/","",$number) // the result would be : 1944UN31KEP2017
我可以在使用之前将我的 $number 变量访问到 js(在 laravel blade 中):
onClick="doPrintTxtdaftar({{ $number}});">Print</a>
但是当我替换字符串和第二个变量时:
onClick="doPrintTxtdaftar({{ $number2}});">Print</a>
我在调试器中收到一个错误消息:SyntaxError: identifier starts immediately after numeric literal
它指出了我的第二个变量值:1944UN31KEP2017
有人能帮帮我吗...谢谢
用引号引起来
改变这个:
onClick="doPrintTxtdaftar( {{$number}} )">Print</a>
至:
onClick="doPrintTxtdaftar( '{{$number}}' )">Print</a>
希望这对你有用!!!
所以我有这个变量
$number = "1944/UN31/KEP/2017"
然后我想将 "/"
替换为 ""
所以我创建了新变量:
$number2 = str_replace("/","",$number) // the result would be : 1944UN31KEP2017
我可以在使用之前将我的 $number 变量访问到 js(在 laravel blade 中):
onClick="doPrintTxtdaftar({{ $number}});">Print</a>
但是当我替换字符串和第二个变量时:
onClick="doPrintTxtdaftar({{ $number2}});">Print</a>
我在调试器中收到一个错误消息:SyntaxError: identifier starts immediately after numeric literal
它指出了我的第二个变量值:1944UN31KEP2017
有人能帮帮我吗...谢谢
用引号引起来
改变这个:
onClick="doPrintTxtdaftar( {{$number}} )">Print</a>
至:
onClick="doPrintTxtdaftar( '{{$number}}' )">Print</a>
希望这对你有用!!!