Is there any way to pass PHP object as JavaScript parameter in HTML? -
i project using laravel 5. show table view , want when click link pass data value data javascript function. try several way cannot it.
@foreach ($basl_officers $basl_officer) <tr> <td><a href="#" onclick="functionone($basl_officer)" >{{ $basl_officer->officername }} </a></td> <td align='center'> {!! form::open(['method' => 'delete', 'route'=>['basl_officers_page.destroy',$basl_officer->id]]) !!} <a href="{{route('basl_officers_page.edit',$basl_officer->id)}}" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-pencil"></span> </a>     <button type="submit" class="btn btn-default btn-sm" onclick="return confirm('are sure?')"> <span class="glyphicon glyphicon-trash"></span> </button> {!! form::close() !!} </td> </tr> @endforeach
javascript code
<script type="text/javascript"> function functionone(x) { alert('you clicked top text' + x); } function functiontwo() { alert('you clicked bottom text'); }
you try this:
onclick="functionone({{ json_encode($basl_officer) }})"
Comments
Post a Comment