I wrote this very short php page to test the javascript function submit().
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head></head><body>
<form id="myform" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<input id="myinput" name="myinputname" type="hidden">
</form>
<?php
echo "<pre>Content of \$_POST\n";
print_r($_POST);
echo "</pre>";
echo "<a href=\"\" onclick=\"examine('Hello')\">examine</a>";
?>
<script type="text/javascript" >
function examine(parametre) {
document.getElementById('myinput').value = parametre;
document.getElementById('myform').submit();
}
</script>
</body></html>
When the "examine" link is clicked, the submit function is executed, but after the "action" has reloaded the page, the $_POST array is empty !
If I put a breakpoint on the submit function (using the debugger of my firefox browser) and then step over that function, the $_POST array is OK.
I try to understand why this behavior occurs. Is it a timing problem ?
The same with the other php page here attached.
Thanks for any advice.
submit-test2.php