3
I have a div which is actually a Bootstrap 4 modal. What I want is that when the user clicks the button, the scroll descends to the end of this div, so that the alertSuccess() message is displayed correctly to the user. Until the moment when the user clicks on the button, the modal covers the success message, which is fixed at the bottom of the screen. That’s why I need the page to go down. I would like to do this with javascript.
<form method="post" action="recebeDados.php" class="form_comment" id="form_comment<?= $row['product_id'] ?>" name="<?= $row['product_id'] ?>">
<h2 class="text-center text-muted" style="font-size: 18px;">Deixe um comentário:</h2>
<div class="form-group">
<input class="form-control" type="name" name="nome" id="nome" value="<?= $_SESSION['nome'] ?>">
</div>
<div class="form-group">
<textarea class="form-control" type="comentario" name="comentario" id="comentario" placeholder="Digite aqui seu comentário" required></textarea>
</div>
<input class="form-control" type="hidden" value="<?= $_SESSION['id_usuario'] ?>" id="id_usuario" name="id_usuario">
<input class="form-control" type="hidden" value="<?= $row['product_id'] ?>" id="product_id" name="product_id">
<div class="form-group">
<input type="submit" onclick="alertSuccess()" class="btn btn-info mx-0 mx-auto text-center" name="submit" value="Comentar"> <!--- BOTÃO -->
</div>
</form>
<script type="text/javascript" language="Javascript">
function alertSuccess()
{
const Toast = Swal.mixin({
toast: true,
position: 'bottom',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
onOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: 'success',
title: 'Signed in successfully'
})
}
</script>
scrollBy()
. even worked, but all scroll goes down to the bottom of the page, not the modal, the modal remains intact.– user161169