|
我的asp学习笔记-Variables |
Author:咖啡虫 PublishTime:2004-6-14 |
1.Create a variable
<html>
<body>
<%
dim name
name="Donald Duck"
response.write("My name is: " & name)
%>
</body>
</html>
2.Create an array
<html>
<body>
<%
Dim famname(6),i
famname(1) = "Jan Egil"
famname(2) = "Tove"
famname(3) = "Hege"
famname(4) = "Stale"
famname(5) = "Kai Jim"
famname(6) = "Borge"
For i = 1 to 6
response.write(famname(i) & "<br />")
Next
%>
</body>
</html>
3.Looping through HTML headers
<html>
<body>
<%
dim i
for i=1 to 6
response.write("<h" & i & ">Header " & i & "</h" & i & ">")
next
%>
</body>
</html>
4.Time-based greeting using VBScript
<html>
<body>
<%
dim h
h=hour(now())
response.write("
" & now())
response.write(" (Norwegian Time)
")
If h<12 then
response.write("Good Morning!")
else
response.write("Good day!")
end if
%>
</body>
</html>
5.Time-based greeting using javascript
<html>
<body>
<%
var d=new Date()
var h=d.getHours()
Response.Write("
")
Response.Write(d + " (Norwegian Time)")
Response.Write("
")
if (h<12)
{
Response.Write("Good Morning!")
}
else
{
Response.Write("Good day!")
}
%>
</body>
</html>
|
| | |