I’m working for a client and I need to generate a coupon number on the fly. I found a javascript that works a charm in generating a random number. The problem is that I need to input the random number that’s generated into another field – capture it somehow. My javascript knowledge is limited. Any suggestion or help is greatly appreciated.
<script type="text/javascript">
function randomnumber() {
document.forms[0].randomnumber.value=(Math.round(Math.random()*9999999999999999+1));
}
onload=randomnumber
</script>
</head>
<body>
<form>
<input id="randomnumber"type="text" name="randomnumber" readonly>
</form>
It sounds like you need to store the random number to use in multiple places: