mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-03 09:43:33 +02:00
Merge pull request #2477 from cisagov/rh/1261-hide-urbanization
ISSUE #1261: Hide urbanization field if non-PR
This commit is contained in:
commit
cc043b5c91
2 changed files with 35 additions and 2 deletions
|
@ -657,6 +657,34 @@ function hideDeletedForms() {
|
|||
});
|
||||
}
|
||||
|
||||
// Checks for if we want to display Urbanization or not
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var stateTerritoryField = document.querySelector('select[name="organization_contact-state_territory"]');
|
||||
|
||||
if (!stateTerritoryField) {
|
||||
return; // Exit if the field not found
|
||||
}
|
||||
|
||||
setupUrbanizationToggle(stateTerritoryField);
|
||||
});
|
||||
|
||||
function setupUrbanizationToggle(stateTerritoryField) {
|
||||
var urbanizationField = document.getElementById('urbanization-field');
|
||||
|
||||
function toggleUrbanizationField() {
|
||||
// Checking specifically for Puerto Rico only
|
||||
if (stateTerritoryField.value === 'PR') {
|
||||
urbanizationField.style.display = 'block';
|
||||
} else {
|
||||
urbanizationField.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
toggleUrbanizationField();
|
||||
|
||||
stateTerritoryField.addEventListener('change', toggleUrbanizationField);
|
||||
}
|
||||
|
||||
/**
|
||||
* An IIFE that attaches a click handler for our dynamic formsets
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% extends 'domain_request_form.html' %}
|
||||
{% load field_helpers url_helpers %}
|
||||
{% load field_helpers url_helpers static %}
|
||||
|
||||
{% block form_instructions %}
|
||||
<p>If your domain request is approved, the name of your organization and your city/state will be listed in <a href="{% public_site_url 'about/data/' %}" target="_blank">.gov’s public data.</a></p>
|
||||
|
@ -37,7 +37,12 @@
|
|||
{% input_with_errors forms.0.zipcode %}
|
||||
{% endwith %}
|
||||
|
||||
{% input_with_errors forms.0.urbanization %}
|
||||
<div id="urbanization-field" style="display: none;">
|
||||
{% input_with_errors forms.0.urbanization %}
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
{% endblock %}
|
||||
|
||||
<script src="{% static 'js/get-gov.js' %}" defer></script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue