Skip to content
Advertisement

How to get array id in ajax append?

i have an appended, there a selectbox with 2 textbox

first the selectbox will selecting an item, after on change, it will set all the textbox with data based on selected. my select option calling data from database array $data.

this is my ajax code

JavaScript

this is my form

JavaScript

lets pass about query data, because its worked. and this is my view as result enter image description here

my second textbox not working, pls help me, thanks

Edited: Let me explain more. the target is textbox stock sisa, and textbox harga_jual the $dBarang created like this, $row just like $i=0, for cheching last data on database

JavaScript

Advertisement

Answer

You can pass this as well inside your function where this refer to current select-box where change has been taken place. Then , using this you can use $(el).closest('.outer').find('.harga_jual').. to add input values to required inputs only.

Demo Code :

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