Skip to content Skip to sidebar Skip to footer

Show A Hidden Div After Form Submit

I save the data using POST method from a form. After the data has been saved, page reloaded, I want to show a hidden div in the page. onsubmit='showHide(this); return false;' sho

Solution 1:

No data will be sent since you have a return false; in your onSubmit.

If you want the user to stay on the same page, you'll need Ajax. Else, you have to show your div on the page that receives the data from your form.


Solution 2:

You have to display the div after the reload.
onsubmit will display it right away (on the same page). So check if the $_POST is set in php after reloading the site and then display the div

Example

<?php
if (isset($_POST)):
?>
    <div>Saved successfully</div>
<?php
endif;
?>

Solution 3:

You might try something like this after reloading the page, instead of onsubmit:

$POST = $POST['myPost'];
      $Message = '<script type="text/javascript">';
      $Message .= 'document.getElementById("' . $IDName . '").style.display="block";'; // Show the hidden DIV
      $Message .= 'document.getElementById("' . $IDName . '").innerHTML="' . $POST . '";'; // Output POST value
      $Message .= '</script>';
echo $Message;

Post a Comment for "Show A Hidden Div After Form Submit"