我有一个选择选项,如下所示。不能在选择的onChange函数中通过叶片变量
@foreach($destinations as $destination)
{!! Form::select('destination', $counts, $destination->ordering, array('onchange'=>'fetch_select(this.value,$destination->id)') !!}
@endforeach
我想在上面的onchange函数中传递一个名为$ destination-> id的变量,这将在后面的java-script中触发一个函数。但是,我无法像上面所做的那样通过这个变量。引发了很多错误。它说
Uncaught SyntaxError: Unexpected token >
在检查控制台。
我试着用:
'onchange'=>'fetch_select(this.value,destination->id)'
'onchange'=>'fetch_select(this.value,"$destination->id")'
'onchange'=>'fetch_select(this.value,(destination->id))'
'onchange'=>'fetch_select(this.value,($destination->id))'
他们没有工作。我怎样才能解决这个搞定。此致敬礼