// Code snippet <SCRIPT type = "text/JavaScript">/* automatically generate a random bill */function getckd () {var d = document. getelementbyid ("billno"); var date = new date (); var year1 = date. getutcfullyear (). tostring (). substring (2, 4); var mouth = date. getmonth () + 1; var day = date. getdate (); var hour = date. gethours (); var minute = date. getminutes (); var seconds = date. getseconds (); var haomiao = date. getmilliseconds (); var random = (math. random () * 100); var CKD = "CKD" + year1 + mouth + day + hour + minute + seconds + haomiao + random. tostring (). substring (0, 2); D. setattribute ("value", CKD) ;}</SCRIPT>
VaR d = Document. getelementbyid ("billno ");
Document is a built-in object that can be directly used on the page without the need to declare and define it.
Getelementbyid:
Purpose: Generally, the ID on the page is unique and used for preparation as an element. The parameter must be of the string type.
Return Value: return the first object with the same ID in the order displayed on the page. If no matching object is found, null is returned.
Document. getelementbyid ("billno"); indicates to obtain the control object of the specified billno according to the specified billno.
Document. getelementbyid ("billno"). Value: obtains the value of the billno element.
Date (): returns the date and time of the current day.
Getutcfullyear (): returns four digits of the Year in UTC format. UTC indicates the Coordinated Universal Time, also known as the unified time in the world.
Getfullyear (); returns four digits indicating the year. It may be different from getutcfullyear.
Getmonth (): Get the current month (0 ~ 11 indicates, 0 indicates July)
Getdate (): Get the current day (1 ~ 31)
Getday (): returns X of the current week (0 ~ 6 indicates, 0 indicates Sunday)
Gettime (): Get the current time (the number of milliseconds since January 1)
Gethours (): Get the current hour (0 ~ 23)
Getminutes (): Get the current number of minutes (0 ~ 59)
Getseconds (): returns the number of seconds (0 ~ 59)
Getmilliseconds (): Get the current number of milliseconds (from 0 ~ 999)
Getlocaledatestring (): Get the current date
Tolocaletimestring (): Get the current time
Tolocalestring (): Get the current date and time