Generate a random number for order ID

Need help…

I am trying to generate a random number for order ID which will get posted in the form field. This is the code… but it jus aint working…!!!

<form action="https://www.abcdefg.com/shop/cc_details.jsp" method="post">
    <div><b style="font-family: arial, helvetica, freesans, sans-serif; font-size: 36px;"><font style="font-size: 16px;"><font face="Garamond, Times, serif"><font style="font-size: 22px;"><font color="#080808" style="font-size: 20px;"><br />
    Try It and see the Difference..!!&nbsp;</font></font></font></font></b></div>
    <b><font color="#080808"><font><font><font><font face="Garamond, Times, serif" style="font-family: arial, helvetica, freesans, sans-serif; font-size: 16px;"><font style="font-size: 11px;">
    </font>
    </font>
    </font>
    </font>
    </font>
    </font>
    </b>
    <ul style="font-family: arial, helvetica, freesans, sans-serif; font-size: 11px; font-style: normal;">
    </ul>
    <font color="#080808" style="font-family: arial, helvetica, freesans, sans-serif; font-size: 18px; font-style: normal;"><b><font face="Garamond, Times, serif"><font><font style="font-size: 18px;"><font style="font-size: 18px;">Name &nbsp; &nbsp;:&nbsp;</font><input name="billing_cust_name" style="border: 1px solid black; height: 25px; font-size: 18px;" type="text" size="15" /><font style="font-size: 18px;">&nbsp;</font><br />
    </font><br />
    <font style="font-size: 18px;">Address :&nbsp;</font><input name="billing_cust_address" style="border: 1px solid black; height: 25px; font-size: 18px;" type="text" size="15" /><br />
    <font style="font-size: 18px;">&nbsp;</font><font style="font-size: 18px;"><br />
    Contact :&nbsp;</font><input name="billing_cust_tel" style="border: 1px solid black; height: 25px; font-size: 18px;" type="text" size="15" /><font style="font-size: 18px;"><br />
    <br />
    Email &nbsp; :&nbsp;</font><input name="billing_cust_email" style="border: 1px solid black; height: 25px; font-size: 18px;" type="text" size="15" /><br />
    </font><font style="font-size: 18px;"><br />
    Targeted Job Profile &nbsp;<br />
    </font><input name="billing_cust_notes" style="border: 1px solid black; height: 25px; font-size: 18px;" type="text" size="25" /></font></b></font><font color="#080808" style="font-family: arial, helvetica, freesans, sans-serif; font-size: 18px; font-style: normal;"><b>&nbsp; &nbsp;&nbsp;<input type="submit" size="100" value="Submit"/><br />
    <br />
    </b></font>
    <input name="Amount" type="hidden" value="5000" />
    <input name="Merchant_Id" type="hidden" value="abcdefgh" />
    <input type="hidden" name="Order_Id">
<script>
now = new Date();
randomNum = '';
randomNum += Math.round(Math.random()*9);
randomNum += Math.round(Math.random()*9);
randomNum += now.getTime();
document.formName.Order_Id.value = randomNum
</script>
</form>

The problem is your trying to target a form that doesn’t exist, see the below which will fix the issue.

Replace

document.formName.Order_Id.value = randomNum

With

document.getElementsByName('Order_Id')[0].value = randomNum