<ul class="list-unstyled">
<a href="javascript:void(0);" id="listByStationsBtn">Показать по выбранным станциям</a>
{% for stationItem in item.children %}
<li>{% if stationItem.label != 'all_stations' %}<input type="checkbox" name="stations[]" value="{{ stationItem.extras.routes[0].parameters.station }}" />{% endif %}<a href="{{ stationItem.uri }}">{{ stationItem.label }}</a></li>
{% endfor %}
</ul>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
let listByStationsBtn = document.querySelector('#listByStationsBtn');
listByStationsBtn.addEventListener('click', function () {
listByStationsBtn.style.display = 'none';
let url = '{{ path('profile_list.list_by_stations', {city:app.request.get('city').uriIdentity, stations: '_stations_'|raw}) }}';
let stationIds = [];
document.querySelectorAll('input[name="stations[]"]').forEach(function (el) {
if(el.checked) {
stationIds.push(el.value);
//можно выбрать не более 130 = 1950 символов + ~40 символов урл
if(stationIds.length == 130) {
return;
}
}
});
window.location = url.replace('_stations_', stationIds.join(','));
});
});
</script>