Leon,
since you can't call a fuinction from a value="", you have to have that function execute automatically. There are 2 ways to do this. The easiest way is to have a javascript assign the value to the hidden field...
<form name="yo">
<input type=hidden value='' name="pwd">
<script>
document.yo.pwd.value=random_password;
</script>
</form>
The only thing is, this javascript must come after the hidden field, otherwise the field won't be there yet when the script tries to assign a value and you'll get an error.
The other way is to build a function and pass the field name to it...
<script>
function giveItValue(g){
document.yo[g].value=random_password;
}
</script>
<form name="yo">
<input type=hidden value='' name="pwd">
<script>
giveItValue("pwd")
</script>
</form>
You should try it with the field not hidden to see it work. Otherwise you won't be able to tell (by viewing the page source).