Fix listeners
This commit is contained in:
29
new-tool.md
29
new-tool.md
@@ -172,14 +172,17 @@ date = ${date}
|
|||||||
<!-- <label for="other-applications">Other:</label> -->
|
<!-- <label for="other-applications">Other:</label> -->
|
||||||
<input type="text" id="other-applications" placeholder="Other application">
|
<input type="text" id="other-applications" placeholder="Other application">
|
||||||
<script>
|
<script>
|
||||||
document.getElementById('other-applications').addEventListener('input', function() {
|
document.getElementById('other-applications').addEventListener('input', updateApplications);
|
||||||
const otherValue = this.value.trim();
|
Array.from(document.querySelectorAll('#applications-checkboxes input[type="checkbox"]')).forEach(cb => {
|
||||||
const checkboxes = Array.from(document.querySelectorAll('#applications-checkboxes input[type="checkbox"]:checked'))
|
cb.addEventListener('change', updateApplications);
|
||||||
.map(cb => cb.value);
|
});
|
||||||
|
function updateApplications() {
|
||||||
|
const otherValue = document.getElementById('other-applications').value.trim();
|
||||||
|
const checkboxes = Array.from(document.querySelectorAll('#applications-checkboxes input[type="checkbox"]:checked')).map(cb => cb.value);
|
||||||
const applications = otherValue ? [...checkboxes, otherValue] : checkboxes;
|
const applications = otherValue ? [...checkboxes, otherValue] : checkboxes;
|
||||||
document.getElementById('applications').value = applications.join(', ');
|
document.getElementById('applications').value = applications.join(', ');
|
||||||
});
|
}
|
||||||
</script>
|
</script> </script>
|
||||||
<input type="hidden" id="applications">
|
<input type="hidden" id="applications">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -343,14 +346,16 @@ function getCheckedApplications() {
|
|||||||
<!-- <label for="other-interfaces">Other:</label> -->
|
<!-- <label for="other-interfaces">Other:</label> -->
|
||||||
<input type="text" id="other-interfaces" placeholder="Other interface(s), separated by commas">
|
<input type="text" id="other-interfaces" placeholder="Other interface(s), separated by commas">
|
||||||
<script>
|
<script>
|
||||||
document.getElementById('other-interfaces').addEventListener('input', function() {
|
document.getElementById('other-interfaces').addEventListener('input', updateInterfaces);
|
||||||
const otherValues = this.value.split(',').map(s => s.trim()).filter(Boolean);
|
Array.from(document.querySelectorAll('#interfaces-checkboxes input[type="checkbox"]')).forEach(cb => {
|
||||||
const checkboxes = Array.from(document.querySelectorAll('#interfaces-checkboxes input[type="checkbox"]:checked'))
|
cb.addEventListener('change', updateInterfaces);
|
||||||
.map(cb => cb.value);
|
});
|
||||||
|
function updateInterfaces() {
|
||||||
|
const otherValues = document.getElementById('other-interfaces').value.split(',').map(s => s.trim()).filter(Boolean);
|
||||||
|
const checkboxes = Array.from(document.querySelectorAll('#interfaces-checkboxes input[type="checkbox"]:checked')).map(cb => cb.value);
|
||||||
const interfaces = otherValues.length ? [...checkboxes, ...otherValues] : checkboxes;
|
const interfaces = otherValues.length ? [...checkboxes, ...otherValues] : checkboxes;
|
||||||
document.getElementById('interfaces').value = interfaces.join(', ');
|
document.getElementById('interfaces').value = interfaces.join(', ');
|
||||||
});
|
} </script>
|
||||||
</script>
|
|
||||||
<input type="hidden" id="interfaces"> </div>
|
<input type="hidden" id="interfaces"> </div>
|
||||||
</td>
|
</td>
|
||||||
<script>
|
<script>
|
||||||
|
Reference in New Issue
Block a user