I`ve created a code that allows user to choose a city in a select box "City", then a second select box "Area" will be filtered and show only areas within that city, so the user can select multiple areas within one city. The select box "Area" allows multiple selection. So this code works on Firefox, Chrome but not on Iphone (Safari) where all areas of all cities are shown (not filtered):
$('#property_city_submit9').change(function(){
var city = $(this).val();
if(city !== 'all'){
$('#property_area_submit9 option:selected').removeAttr("selected");
$('#property_area_submit9 option').css('display', 'none');
$('#property_area_submit9 option[data-parentcity="'+city+'"]').css('display', 'block');
}else {
$('#property_area_submit9 option:selected').removeAttr("selected");
$('#property_area_submit9 option').css('display', 'none');
$('#property_area_submit9 option[value="all"]').css('display', 'block');
}
});
property_city_submit9
- "City" select boxproperty_area_submit9
- "Area" select box (for multiple selection), its options have attributedata-parentcity
- the name of the city an area belongs to.
I don't understand, the css()
method does not work on Safari? Appreciate all your help.