我有一個選擇選項,如下所示。不能在選擇的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))'
他們沒有工作。我怎樣才能解決這個搞定。此致敬禮