Tuesday, April 3, 2018

JS part 2


//Get From JSON , FIlter , and put in drop down

$.getJSON(
'https://fly.com/stations/file.json', function (list) {

    list = list.filter(function (item) {
        return item.StationType == "A";
    });

    for (var i in list) {
        if (list.hasOwnProperty(i)) {
            optionDes += "<option value='" + list[i].StationCode + "'>" + list[i].StationName + " (" + list[i].StationCode + ")</option>";
        }
    }

    optionDes += "</select>";
    document.getElementById("origin").innerHTML = optionDes;

No comments:

Post a Comment