Displays the morning or afternoon on the jsp page according to the current time.

Source: Internet
Author: User

Displays the morning or afternoon on the jsp page according to the current time.

If the following code is used on the jsp page

<% If (new Date (). getHours ()> = 0 & new Date (). getHours () <= 12) {// check whether the current time is between and PM. %> Good morning <%} else {%> Good afternoon <%} %>

Example:

<Div class = "fitem"> <label> time type: </label> <input id = "timeType" name = "timeType" class = "easyui-combobox" required = "true" data-options = "valueField: 'value ', textField: 'label', value: 1, <% if (new Date (). getHours ()> = 0 & new Date (). getHours () <= 12) {// check whether the current time is between PM and PM. %> data: [{'label': 'more', 'value ': 1, 'selected': true}, {'label': 'Afternoon ', 'value': 2}] "<%} else {%> data: [{'label': 'Afternoon ', 'value': 2, 'selected': true}] "<% }%> </div>


Urgent! JSP page, use the script information to determine the current time, and output information such as "Morning", "Noon", "Afternoon", and "Evening" according to the time period

Js: written in head:
<Script>
Var da = new Date ();
Function show (){
Var hournow = da. getHours ();
If (hournow <8 ){
Document. getElementById ("today1"). value = "Morning ";
}
If (8 <= hournow <12 ){
Document. getElementById ("today1"). value = "Morning ";
}
If (12 <= hournow <= 13 ){
Document. getElementById ("today1"). value = "Noon ";
}
If (13 Document. getElementById ("today1"). value = "Afternoon ";
}
If (hournow> 18 ){
Document. getElementById ("today1"). value = "Evening ";
}
SetTimeout ("show ()", 10000); // execute once every 10 seconds
}
</Script>
Body:
<Body onload = "show ()">
<Input type = "text" id = "today1"/>
</Body>

Compile a web program to display the morning and afternoon in the jsp industry according to time

If the following code is used on the jsp page

<%
If (new Date (). getHours ()> = 0 & new Date (). getHours () <= 12) {// check whether the current time is between and noon.
%>
Good morning

<%
}
Else {
%>
Good afternoon

<%
}
%>

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.