hendraspt hendraspt - 3 months ago 24
jQuery Question

How to get the 'id' of the data in datatables to display the data in the update form?

I am using laravel and datatables. I want to update the data, but I don't know how to get the id of the data in my datatables if the update form is a new page/link.
If the update form is a modal/popup, I am using:

<a type="button" data-toggle="modal" data-target="#update_modal" onclick="update_modal('{{ $getData->data_id }}')"></a>

In the javascript:

<script type="text/javascript">
function update_modal(data_id) {

And it will display the data on my database to a textbox in a modal. But how if I want to make that modal is not a modal, but a new page?
what should I do with this:

<a href="{{ route('UpdateData')}}" type="button"></a>


You could pass the variable data_id as parameter to the new page through the route :

<a href="{{ route('UpdateData',['data_id'=>$getData->data_id])}}" type="button"></a>

Then in the input #update_id_text assign this value using :

<input type="text" value="{{$data_id}}" id="update_id_text"/> 

Or you could get it in controller the using INPUT::get(), like :

$data_id = INPUT::get("data_id");

Hope this helps.