I want to display a customized alert when i click a but if im logged in i want to redirect to another page. I have this.
<div id="contentCalendar" class="col-md-3 images_1_of_4 text-center">
<a><img onClick="show_alert();" id="rotateme" class="img-responsive img-circle center-block" src="web/images/calendaricon.png"/></a>
<h4><a href="#">Check our last events</a></h4>
</div>
<div id="myalert" class="alert alert-error">
<a href="#" class="close" data-dismiss="alert">×</a>
<strong>Error!</strong> You must be logged in to see our calendar.
</div>
<script>
$('#myalert').hide();
//What happen if you want to enter the events without loggin.
var logged_in = <?php echo ($logged_in); ?>;
function show_alert()
{
if(logged_in==true)
{
window.location="timeline.php";
}
else
{
$('#myalert').show();
}
}
</script>
For some reason works like a charm when Logged_in is true and i get redirected. But when im logged out it just doesnt show the alert even if i didnt press the button at all.
Any ideas?