this is my JS:
function showErrorMsg() {
modal.style.display = "block";
}
I want to call that function via php:
if(empty($from) || empty($first_name) || empty($last_name) || empty($_POST['message'])) {
// CALL showErrorMsg();
}
The PHP line is called whenever I click a button in a mail-form, and it checks if any of the fields are empty.
I tried this:
if(empty($from) || empty($first_name) || empty($last_name) || empty($_POST['message'])) {
echo "<script type='text/javascript'>showErrorMsg();</script>"
} else {
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
But that gave me an HTTP 500 error..
The JS is in its own file called modal.js
.
NOTE: The JS is basically just a example. There's alot more confusing stuff in it, so a JS function is needed. Just wanted to clarify this before someone came and gave me tips on how PHP can change style properties. ;)