Function of document. getelementbyid ("billno ")

Source: Internet
Author: User

// 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




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.