I have a vector layer in GeoServer which basically has 14 line/fields/polyline attributes
I want the list of only those stations in the 2nd dropdown of end station which are actually related
Like 5 out of 14 lines
in the shapefile (highlighted with yellow)
are originating/starting
from New Delhi.
FID Start_station End_Station
306 New Delhi Ambala
307 New Delhi Rohtak
1230 New Delhi Saharanpur
1231 New Delhi Hapur
1232 New Delhi Aligarh
I am fetching the attributes from column named FROM_
in the shapefile in the dropdown as
var select_from = $('#from_station');
var from_station_Array = new Array();
Railway_Layer.getSource().on('addfeature', function (e) {
const name = e.feature.get('FROM_');
var value_station_from = String(name);
if (jQuery.inArray(value_station_from, from_station_Array) == -1) {
select_from.append(
"<option class='ddindent'>" + value_station_from + '</option>'
);
from_station_Array.push(value_station_from);
}
// console.log('FROM_ station names are ', name);
});
& I am fetching the attributes from column named TO
in the shapefile in the dropdown as
var select_to = $('#to_station');
var to_station_Array = new Array();
Railway_Layer.getSource().on('addfeature', function (e) {
const name = e.feature.get('TO');
var value_station_to = String(name);
if (jQuery.inArray(value_station_to, to_station_Array) == -1) {
select_to.append(
"<option class='ddindent'>" + value_station_to + '</option>'
);
to_station_Array.push(value_station_to);
}
// console.log('TO_ station names are ', name);
});
I want if I Select New Delhi from 1st dropdown, then only these 5 stations viz: Ambala, Rohtak, Saharanpur, Hapur, Aligarh
whose originating point is New Delhi
should appear in the 2nd dropdown, instead of whole list.
Currently, the whole list appears here in the 2nd dropdown.
In case if I select New Delhi
from 1st dropdown, and any value, to whom New Delhi
is not related i.e. not an originating point then the query does not run.
e.g: if I select New Delhi
from 1st dropdown & Kurukshetra
from 2nd, it will not work, as New Delhi
in the shapefile does not have Kurukshetra
as its related attribute
Manually assigning them values and then Mapping with JQuery is not feasible as there are lot of stations, which keep on changing/updating.
so basically, How to map values from a column based on another column in the shapefile?
To Station
be allowed ifFrom Station
is not selected yet?either ways
/both ways
, if we selectFrom Station
first then, onlyrelated
/relevant
stations should appear inTo Station
dropdown, or if we selectTo Station
first, then only related stations should appear inFrom station
dropdown. that way we don't need to block selection ofTo Station
To Station
, you then limit what is available inFrom Station
. But if you then select fromFrom Station
you will have to limit what is available inTo Station
and so on. Might be confusing for end user.To Station
should not be allowed until some value fromFrom Station
is not selected.