简体   繁体   中英

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;" 

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>

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.

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;
?>

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM