Reputation: 153
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;"
shows the specified div but does not save data.
any ideas?
LE:
to make it more complicated: the form that trigges the page reload is on the div that i want to re-show. initialy i make the div visible with:
<a class="articleLink" href="javascript:void(0);" onclick='$("#ModAdd<?php echo $rrows['id_']; ?>").show("slow");'></a>
Upvotes: 0
Views: 1451
Reputation: 11809
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;
Upvotes: 0
Reputation: 866
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.
Upvotes: 2
Reputation: 11392
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;
?>
Upvotes: 0