Skip to content
Advertisement

ajax select data with multiple related data

i want to show checkbox looping from db, if i try to select data id_kendaraan in field then show the data from that id.

this my view code:

JavaScript

my controller:

JavaScript

i get data from view $id_kendaraan for my parameter.

this my model:

JavaScript

but if i try this code, field tahun_beli, id jenis is success to showing in the view. but the checkbox from sparepart is looping exaggerated.

i try the json, the data is correct, show tahun_beli, id_jenis, is show and sparepart is show by id_jenis json manual

but in view i try this code… tahun_beli and id_jenis is correct show one data, but sparepart is looping 3 times.. sparepart should be show data 1 times… looping sparepart

Advertisement

Answer

I checked your code and I think the issue is at this one:

JavaScript

try to remove the first $.each, your code would be like this

JavaScript

Hopefully it works

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement