How can I create a dynamic tag with ajax call?

offimiPat

New Member
I want to create icons according to the number of passengers and I want to give each icon an id.The passenger ids is in php code.How can I give the id of the passenger to the icon id.When par_key is id, par_value should be id of that passenger. \[code\]function sta_callStation() { var distName; var count = 0; $('#noOfPassengers, #infoOfPassengers, #distType,#distParams').empty(); $('#sta_numberOfIcons').empty(); $.getJSON('StationInfoGenerator.php', function (station) { $.each(station, function (sta_key, sta_value) { if (sta_key == "numberOfPassengers") { $('#noOfPassengers').append("<strong>?stasyondaki Yolcu Say?s?: </strong>" + sta_value); } if (sta_key == "passengers") { $('#infoOfPassengers').append("<strong>Passengers Information:</strong>" + '<br/>'); $.each(station.passengers, function (i, passenger) { // $('#sta_numberOfIcons').append('<i class="icon-user" id = "sta_numberOfIcons" > < /i>'); $.each(passenger, function(par_key, par_value) { if(par_key=="pas_id") { var icon = document.createElement("i"); // icon.id = par_value; input.setAttribute("id", par_value); icon.setAttribute("class", "icon-user"); document.getElementById("sta_numberOfIcons").appendChild(icon); } $(function () { $("#sta_numberOfIcons").popover({ title: 'Passenger Information', content: (par_key + ': ' + par_value + ' ' + '<br/>') }); $('#infoOfPassengers').append(par_key + ': ' + par_value + ' ' + '<br/>'); }); }); $('#infoOfPassengers').append('<hr />'); count++; }); }\[/code\]
 
Back
Top