forked from ckan/ckanext-scheming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27035f4
commit 5f063a4
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
ckanext/scheming/templates/scheming/form_snippets/custom.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{% import 'macros/form.html' as form %} | ||
|
||
|
||
{{ form.select('country', label=_('Country'), options=[{'name':'France', 'value': 'France'},{'name': 'Austria', 'value': 'Austria'}], selected='Austria', error='') }} | ||
{{ form.select('city', label=_('City'), options='', error='') }} | ||
<!-- <form> | ||
<label for="country">Select Country:</label> | ||
<select id="country"> | ||
<option value="">Select a country</option> | ||
<option value="France">France</option> | ||
<option value="Austria">Austria</option> | ||
</select> | ||
<label for="city">Select City:</label> | ||
<select id="city"> | ||
<option value="">Select a city</option> | ||
</select> | ||
</form> --> | ||
|
||
|
||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const cityOptions = { | ||
France: ['Paris', 'Lyon', 'Marseille', 'Nice'], | ||
Austria: ['Vienna', 'Salzburg', 'Graz', 'Innsbruck'] | ||
}; | ||
|
||
const countrySelect = document.getElementById('country'); | ||
const citySelect = document.getElementById('city'); | ||
|
||
countrySelect.addEventListener('change', function() { | ||
const selectedCountry = countrySelect.value; | ||
const cities = cityOptions[selectedCountry] || []; | ||
citySelect.innerHTML = '<option value="">Select a city</option>'; // Reset the city dropdown | ||
|
||
cities.forEach(function(city) { | ||
const option = document.createElement('option'); | ||
option.value = city; | ||
option.textContent = city; | ||
citySelect.appendChild(option); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
|
||
|
||
|
||
|