Long ago again, I needed to pass js result to php.
I hate hidden fields as they are not easy to spot if the code file is gigantic. Yet, i must say one way is to use an hidden field in the form to put the result:
<script type="text/javascript"> function sayHello(str, n) { // replace by your own function return str+n; } window.onload = function() { document.getElementsByTagName("form")[0].onsubmit = function() { document.getElementById("parameterFromPrevPage").value = sayHello('jazz', 12); } } </script> <form method="POST" action="catch.php"> <input type="hidden" name="parameterFromPrevPage" />
Another way is:
<form method = "Post" action = "catch.php" onsubmit="this.action=this.action+sa yHello('ja zz', 12);"