I'm wondering if this is something I can do. I have a PHP script that needs to call a function that I define in my main index.php.
Inside my other PHP file I have:
echo "<script>ShowModal('PopUpNameItem','closeNameItem');</script>";
and inside my main index.php I have that function. how do I actually call this from a seperate script? Normally you would use something like this but since my files are .php can I do this?
<script type="text/javascript" src="ajax.js"></script>
and this is the function I'm trying to call
function ShowModal(popup, closeBtn) {
var modal = document.getElementById(popup);
var span = document.getElementsByClassName(closeBtn)[0];
modal.style.display = "block";
span.onclick = function() {
modal.style.display = "none";
}
if (modal != "PopUpNameItem") {
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
}
}