You can also do it without changing the main page's navigation by using an iframe. I'll do a quick dummy example:
First you make a page with your form on it, say it was called hiddenform.htm:
code:
<form name="hiddenForm" method="POST" target="myurlwhichtakespostdata.php"><input type="hidden" id="variableToSend" value=""></form>
Once you've done that, you can stick it on the following page with all the relevant javascript:
code:
<script language="Javascript"><!-- function sendData(theData){
document.all.myiFrame.getElementById('variableToSend').value = theData ;
document.all.myiFrame.forms['hiddenForm'].submit() ;
}
-->
</script>
<!-- All your page scripting here, run the javascript function sendData('whatever') when you wanna send the data -->
<iframe src="hiddenform.htm" frameborder="0" scrolling="NO" width="1" height="1"></iframe>
And you're done