display ajax response in form input box - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: display ajax response in form input box (/showthread.php?tid=68000) |
display ajax response in form input box - apysan - 05-07-2017 Hi I have got this json array from controller {"plan_id":"7","plan_title":"GOLD","plan_price":"999","resume_limit":"12000","day_limit":"364","job_limit":"20","user":"1","day_break":"0"} Now i want to display the values in the forms input I try this but it does not display the plan_price (999) in the input field document.getElementById("plan_price").value = data.plan_price; Please help RE: display ajax response in form input box - natanfelles - 05-07-2017 Same question... https://www.google.com/search?q=add+value+to+input+field+javascript According to your attached image is possible see that your resume_limit is an object. Add console.log(data) after the variable data and check the responses. RE: display ajax response in form input box - arma7x - 05-07-2017 Are you sure output content-type is application/json? RE: display ajax response in form input box - apysan - 05-07-2017 i check with console.log it display value correctly, also the json values are showing correctly. Still i am unable to display array[0] in 1st input box array[1] in 2st input box array[2] in 3rd input box array[3] in 4th input box Help is appreciated. RE: display ajax response in form input box - apysan - 05-07-2017 (05-07-2017, 12:05 PM)arma7x Wrote: Are you sure output content-type is application/json? yes RE: display ajax response in form input box - arma7x - 05-07-2017 You can enumerate data object for ( var key in data) { if (data.hasOwnProperty(key)) { console.log(key + " -> " + data [key]); } } RE: display ajax response in form input box - arma7x - 05-07-2017 Take a look at this http://stackoverflow.com/questions/4968406/javascript-property-access-dot-notation-vs-brackets RE: display ajax response in form input box - natanfelles - 05-07-2017 Do your fields have the appropriate ids? You can post your form and js code. |