- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Try to only fire Messagebox on Save
In a form when a user clicks save I want a messagebox dialogue to display a confirmation message.
<script>
$(function(){
$(document).click(function(){
$('.messagebox').hide();
});
});
</script>
If I use this php inside the HTML the messagebox is displayed by default on page load even where there is no message to display. Clicking it hides it.
<?php if(isset($_SESSION['message'])){ ?>
<div class="messagebox">
<?php echo $_SESSION['message']; unset($_SESSION['message']); ?>
</div>
<?php } ?>
I’ve tried the not empty function but the box doesn’t load even on save :
<?php if(isset($_SESSION['message']) && !empty($message)): ?>
<div class="messagebox">
<?php echo $_SESSION['message']; unset($_SESSION['message']); ?>
</div>
<?php endif; ?>
css :
.messagebox {
position:absolute;
background:#810000;
color:#ffffff;
border:3px solid #000000;
font-family: 'Montserrat', sans-serif;
font-size:20px;
height:20px;
width:160px;
z-index:1;
padding:12px 0px 12px 0px;
margin:800px 0px 0px 340px;
text-align:center;
border-radius:10px;
}
If I remove the background colour there is no issue but I want the messagebox to be prominent.
You should probably move this topic to the “PHP Problems” forum… sadly, I don’t know PHP well enough to give you a good answer.
Thanks for the reply. I managed to resolve it but the validation doesn’t work. I’ll post in the php section if I can’t debug.