Forums

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

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #203830
    MBM
    Participant

    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.

    #204267
    Mottie
    Member

    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.

    #204314
    MBM
    Participant

    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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.