Skip to content

Commit

Permalink
Scroll on change
Browse files Browse the repository at this point in the history
  • Loading branch information
Richie314 committed Sep 2, 2024
1 parent 5b24087 commit 4496e65
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions staff/squadre/crea.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<label for="parrocchia">
Parrocchia
</label>
<select name="parrocchia" required>
<select name="parrocchia" required id="parrocchia">
<?php
foreach ($lista_parrocchie as $parr)
{
Expand All @@ -128,7 +128,7 @@
<label for="sport">
Sport
</label>
<select name="sport" required>
<select name="sport" id="sport" required>
<?php
foreach ($lista_sport as $sport)
{
Expand Down Expand Up @@ -173,9 +173,10 @@
if (!isset($last_p) || $last_p !== $iscritto->parrocchia)
{
$last_p = $iscritto->parrocchia;
echo "<li><h3>$last_p</h3></li>\n";
$p_id = $iscritto->id_parrocchia;
echo "<li><h3 data-group='$p_id'>$last_p</h3></li>\n";
}

$label = htmlspecialchars($iscritto->nome);
$id = $iscritto->id;
echo "<li>\n<label for='member-$id'>$label</label>";
Expand Down Expand Up @@ -220,6 +221,17 @@ function UpdateList()
UpdateList();
});
});
const select = document.getElementById('parrocchia');
if (select) {
select.addEventListener('input', () => {
const headers = [... document.querySelectorAll('[data-group="' + select.value + '"]')];
if (headers.length === 0) return;
headers[0].scrollIntoView({
behavior:"smooth",
block:"start",
});
});
}
</script>
</div>
<input class="button rounded" type="submit" value="Conferma" onclick="UpdateList()">
Expand Down

0 comments on commit 4496e65

Please sign in to comment.