nethken nethken - 1 year ago 89
Javascript Question

How to show alert box after the link is click

Hello this is what i want to do. I want to show the alert box after the user click the link. My link is directed to another php page but it will come back again to the page where the link is found. How can i achieve this? Can someone give me ideas on how to do it?

this is what i tried but not working.


function fsa() {
echo '<div class="alert alert-success alert-dismissable" id="success-alert">';
echo '<strong>Successfully posted!</strong>';
echo '</div>';

<a class='btn btn-info left-margin' href="dbf-import.php" onclick="fsa()">Import Database</a>

Answer Source

This is an example to show the dissmissable alert box when clicking on a button.

$(document).ready(function() {
  $('.activater').click(function() {
.alert {
  display: none;
<script src=""></script>
<script src=""></script>
<link href="" rel="stylesheet" />

  <div class="container">
    <h2>Dismissal Alert Messages</h2>
    <button class="activater">Send Message</button>
    <a class="activater">SHOW MESSAGE</a>
    <div class="alert alert-success alert-dismissable">
      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
      Success! message sent successfully.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download