I have this javascript function which allows me to create my custom alerts by calling it using this <script>Alert.render('message goes here');</script>
Javascript:
<script>
function CustomAlert(){
this.render = function(dialog){
var winW = window.innerWidth;
var winH = window.innerHeight;
var dialogoverlay = document.getElementById('dialogoverlay');
var dialogbox = document.getElementById('dialogbox');
dialogoverlay.style.display = "block";
dialogoverlay.style.height = winH+"px";
dialogbox.style.left = (winW/2) - (550 * .5)+"px";
dialogbox.style.top = "200px";
dialogbox.style.display = "block";
document.getElementById('dialogboxhead').innerHTML = "Image Upload Error!";
document.getElementById('dialogboxbody').innerHTML = dialog;
document.getElementById('dialogboxfoot').innerHTML = '<button id = "buttonclose" onclick="Alert.ok()">ok</button>';
}
this.ok = function(){
document.getElementById('dialogbox').style.display = "none";
document.getElementById('dialogoverlay').style.display = "none";
}
}
var Alert = new CustomAlert();
HTML:
<div id = "dialogoverlay"></div>
<div id = "dialogbox">
<div>
<div id = "dialogboxhead"></div>
<div id = "dialogboxbody"></div>
<div id = "dialogboxfoot"></div>
</div>
</div>
Inside the html, I tried calling in the function(Alert.render...) and worked. However, when I tried calling it in the php above the html :
echo "<script>Alert.render('message goes here');</script>";
It doesn't work at all. Any ideas?
UPDATE
Here's the php code:
<?php
if(isset($_POST['btn_sample'])){
echo "<script>Alert.render('sample message');</script>";
}
I added this on the html:
<form action = "" method = "post">
<input type = "submit" name = "btn_sample" value = "sample">
</form>