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
<%
}
%>