SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2013
    Location
    jhkjh
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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..!!!

    HTML Code:
    <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>
    Last edited by Mittineague; Feb 5, 2013 at 19:29. Reason: reformatting bbcode tags

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The problem is your trying to target a form that doesn't exist, see the below which will fix the issue.

    Replace
    Code JavaScript:
    document.formName.Order_Id.value = randomNum

    With
    Code JavaScript:
    document.getElementsByName('Order_Id')[0].value = randomNum


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •