Hi,
I recently finished coding a form for my website, but can’t solve this problem:
In the form there is a dropdown field where the user can choose in which Swedish county they are located (#plats). When the user has chosen county, I want the following dropdown (#kommuner) to show the municipalities in the county, which the user also can choose from:
I created a public javascript file with all the municipalities in each county(these are just 2 of them, there are 23):
And imported them to the site code:
Lastly, I wrote the site code (this is just a part of it):
$w('#plats').onChange(() => {
$w('#kommuner').enable();
if ($w('#plats').value === 'Norrbotten') {
$w('#kommuner').options = norrbottenkommuner;
$w('#kommuner').placeholder = 'Välj Kommun';
$w('#kommuner').enable();
} else if ($w('#plats').value === 'Västerbotten') {
$w('#kommuner').options = västerbottenkommuner;
$w('#kommuner').placeholder = 'Välj Kommun';
$w('#kommuner').enable();
} else if ($w('#plats').value === 'Jämtland') {
$w('#kommuner').options = jämtlandkommuner;
$w('#kommuner').placeholder = 'Välj Kommun';
$w('#kommuner').enable();
} else if ($w('#plats').value === 'Västernorrland') {
$w('#kommuner').options = västernorrlandkommuner;
$w('#kommuner').placeholder = 'Välj Kommun';
$w('#kommuner').enable();
} else {
$w('#kommuner').value = '';
$w('#kommuner').disable();
$w('#kommuner').expand();
}
});
What am I doing wrong? The municipality field doesn’t do anything, just stays disabled even after chosen county. Here is my website: www.atersalj.se/annonsera