Send notification messages from 1 page to another with snackbar

Hello i have a question. Is it possible to send notification messages from 1 page to another with snackbar . So I have a page where I have the prepared dishes (the system is for a restaurant) when the chef prepares the dish and by pressing the button he has to send a message to the waiter that the food is ready.

<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#snackbar {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 2px;
  padding: 16px;
  position: fixed;
  z-index: 1;
  left: 50%;
  bottom: 30px;
  font-size: 17px;
}

#snackbar.show {
  visibility: visible;
  -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
  from {bottom: 0; opacity: 0;} 
  to {bottom: 30px; opacity: 1;}
}

@keyframes fadein {
  from {bottom: 0; opacity: 0;}
  to {bottom: 30px; opacity: 1;}
}

@-webkit-keyframes fadeout {
  from {bottom: 30px; opacity: 1;} 
  to {bottom: 0; opacity: 0;}
}

@keyframes fadeout {
  from {bottom: 30px; opacity: 1;}
  to {bottom: 0; opacity: 0;}
}
</style>
</head>
<body>
<h2>Snackbar / Toast</h2>
<p>Snackbars are often used as a tooltips/popups to show a message at the bottom of the screen.</p>
<p>Click on the button to show the snackbar. It will disappear after 3 seconds.</p>
<button   onclick="myFunction()">Show Snackbar </button>
<div id="snackbar">Food is ready</div>
<script>
function myFunction() {
  var x = document.getElementById("snackbar");
  x.className = "show";
  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>
</body>
</html>```

Well, a “snackbar” is just a pop-over message. The message is saved in text at some point.
Normally, you would get the text for the toast from a database or other saved input. But, if you want to
pass data from page to page, just use a SESSION variable. Sessions are easy to handle. Just start it.
Then, save the data in a SESSION variable on the first page and read it on the second page.
Easy to do!

Sponsor our Newsletter | Privacy Policy | Terms of Service