Parse JSON File for Option in HTML select box -


i'm doing phonegap project company.. here goes on.. have json file named city.json

[{"cityid":1,"cityname":"magelang"},{"cityid":2,"cityname":"jayapura"},{"cityid":3,"cityname":"aceh"}] 

i want city data option in html select box named "city".. had searched on web, couldn't find solution json pattern.. have tried code, didn't work..

$(document).ready(function(){             $.getjson('city.json',              function(data){                 var html = '';                 var len = data.length;                 (var = 0; i< len; i++) {                     html += '<option value="' + data[i].cityid + '">' + data[i].cityname + '</option>';                 }                 $('#city').appendto(html);             });         }); 

i have imported jquery javascript plugin too.. have no idea make works.. please me..

use .append() not .appendto(). way doing trying append $("city") html variable.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -