venkyrao venkyrao - 1 year ago 88
PHP Question

how to load array response from ajax into array input textbox

We are sending data through Ajax call and getting response as array. we want to loop that array and load into array input field. but data not loading into input.

<input type="hidden" name="loadchild[]" id="loadchild[]" >

this textbox is in loop

type: "POST",
url: "asign.php",
data: {plan_id: plan_id},
dataType: "json",
success: function (dta)
here dta['insert_id'] is single value and
dta['child_ids'] are multiple values and i am getting as [1,2,3,4,5] */

for (var i = 0; i < dta['child_ids'].length; i++)
$("#loadchild[" + i + "]").val(dta['child_ids'][i]);

here i am getting as [object Object] when asigning value to textbox

Please let me know how to pass array value one by one into

Answer Source

try this

1)you have to escape the brackets like this

for(var i=0;i<dta['child_ids'].length;i++)


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download