Welcome to TalkGraphics.com
Results 1 to 5 of 5
  1. #1

    Default Generating Unique ID in HTML

    Im trying to generate a Unique ID which can be used as an order number for a form submission made in coffee cup form builder.

    I contacted coffee cup already and was informed that there's no way to generate unique numbers within form builder, so I've been attempting to do this within the invoice script which is generated after the form is submitted.

    It doesn't matter so much what the ID is made up of, I was planning to use a 10 digit code generated from the following:

    <script LANGUAGE="Javascript">
    var stampmonths = new Array( "01","02","03","04","05","06","07","08","09","10", "11","12");
    var thedate = new Date();
    document.write(stampmonths[ thedate.getMonth()] + "" + thedate.getDate() + "" + thedate.getFullYear() + thedate.getSeconds() + "" );
    </script>

    To create: MonthDayYearSecond ... e.g. 0820201450
    Which would be perfectly sufficient - in that it's very unlikely the Unique ID will repeat its self in any given day.



    When previewing the script for the invoice this works perfectly. I did however begin to wonder when the invoice is sent by email will the script create a "stamp" for the given snapshot in time the invoice was generated, or will it keep updating and pull off newly generated numbers each time its viewed? On testing in an email it appears that no numbers at all have been generated, it just hasn't worked. Maybe the Email programme only supports basic html

    My question is, is there a fairly simply way to generate a unique ID, which won't update its self over time?
    It needs to be generated at the same time the invoice is generated. It doesn't matter what it consists of, but it does have to to unique

  2. #2
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,823

    Default Re: Generating Unique ID in HTML

    The script works but it is only writing to the current page, using document.write().
    I assume the ' + "" + ' parts are for literals; at present, they could be removed totally.
    There is no need for the variable stampmonths either, all it is doing is incrementing the month number and padding it to two digits.
    On any given day, the code could repeat every time the minute comes round, that is 1,440 times a day are one chance in sixty.

    For uniqueness all you need is:
    Code:
    <script>
    Code:
    var d = new Date();
    var n = d.getTime();
    </script>
    To render to the current document, you would include document.write(n); just before </script>.

    Variable d will update every time the page/form is opened or refreshed. Once the form is submitted, it is locked.

    To add it to a CoffeeCup form, you need to associate the value of the variable d to an input or other field name.
    To help here, I need an example of the form you have built. I have assumed you do not have CoffeeCup's
    Shopping Cart Designer Pro.

    Acorn

    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  3. #3

    Default Re: Generating Unique ID in HTML

    After contacting Coffecup support again im having another problem in that apparently the HTML section which you're able to insert code into will never show on form results, nor is there any way to call it up. The result will show in the form while you're filling it out online, but it wont reproduce that field in a responder email.

    Im told then only way to make use of the code is to insert it directly into the email responder instead, but inserting it into the email isnt working, just leaves me with a blank space

  4. #4
    Join Date
    May 2014
    Posts
    30

    Default Re: Generating Unique ID in HTML

    To render to the current document, you would include document.write(n); just before </script>.

    this is the correct code please replace with old one.

  5. #5
    Join Date
    Sep 2014
    Location
    New York City
    Posts
    1

    Default Re: Generating Unique ID in HTML

    Thank you nice information share you...

 

 

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
  •