infovision
08-14-2006, 03:09 AM
I'm wanting to have a randomly generated number as the value of a tag each time I reload the page.
<form action="whatever.asp" method="post" name="myform" onsubmit="return ValidateForm(this)">
<input type="hidden" name="v46" value="8773">
</form>
I want to replace the 8773 of the attribute value="8873 with a randomly generated number between 1-9999. So far I have found the code below which generates a random number as the value in a visible input field.
What I need it to do is change in the actual code of the page each time the page reloads for a hidden input value. So evertime you refresh the page the value="8873" in the actual code changes to a different number.
The JavaScript I have so far is
<script type="text/javascript">
var n=9999;
onload=function(){
var rand = Math.ceil(Math.random()*n);
document.forms[0].elements['v46'].value=rand
}
</script>
Any Ideas? Any help would be greatly appreciated.
<form action="whatever.asp" method="post" name="myform" onsubmit="return ValidateForm(this)">
<input type="hidden" name="v46" value="8773">
</form>
I want to replace the 8773 of the attribute value="8873 with a randomly generated number between 1-9999. So far I have found the code below which generates a random number as the value in a visible input field.
What I need it to do is change in the actual code of the page each time the page reloads for a hidden input value. So evertime you refresh the page the value="8873" in the actual code changes to a different number.
The JavaScript I have so far is
<script type="text/javascript">
var n=9999;
onload=function(){
var rand = Math.ceil(Math.random()*n);
document.forms[0].elements['v46'].value=rand
}
</script>
Any Ideas? Any help would be greatly appreciated.