lundi 21 septembre 2015

Is there any way to pass php object as javascript parameter in html?

I do project using Laravel 5. I show table fron view and i want to when click this link pass it is data value all data to javascript function. i am try to several way but cannot do it. plz ,help me.

  @foreach ($basl_officers as $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> &nbsp &nbsp
                                <button type="submit" class="btn btn-default btn-sm" onclick="return confirm('Are you 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 the top text' + x);
}
function functionTwo() {
    alert('You clicked the bottom text');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire