Relatively new to PHP here, but here’s where I’m at:
I have a simple PHP sort of email-sent validation going on, but after the page checks and confirms that the email is sent, I need to call Javascript (unless there is a better way to do this) to hide the DIV containing the email form to prevent spam.
Here’s my code:
<?php
if (isset($_GET['sent']) === true) {
echo '<div id="formAnswer"> Thanks for the email! </div>';
}
if (empty($errors) === false) {
echo '<ul>';
foreach($errors as $error) {
echo '<li>', $error, '</li>';
}
echo '</ul>';
}
?>
I want to hopefully call a Javascript function to hide the div containing the email form based on the same IF statement that confirms the email was sent (I’d like to include setTimeout so that it’s very clear to the user that the confirmation DIV appears, and they can’t send another email from that page), but I can’t seem to get the Javascript to execute within an echo.
Any help?
use document.getElementById(‘divid’);
elem.parentNode.removeChild(elem)
Delete the Div! to hide it 😀