ну например вот так
<html>
<script>
var a;
function A()
{ a=10;
return (a);
}
window.onload = function(){
hid = document.createElement('input');
hid.type = 'hidden';
hid.name = 'perem';
hid.value = A();
document.getElementById("myForm").appendChild( hid );
}
</script>
<body>
<form id="myForm" method="POST">
<input type="submit" id="send" value="Send">
</form>
</body>
</html>