Visual InterDev
Web pages are filled with information for users, but most of it is static. You can use scripts to display dynamic information to the user.
Because client scripts run on the browser, they give you flexibility in how you want to display information to the user. One way is to display message boxes, the way stand-alone applications on a computer often do.
To display message boxes from client scripts
<SCRIPT LANGUAGE="VBScript">
window.alert("Hello, World.")
</SCRIPT>
To reference the current window, you can omit the reference to the window object.
If you are writing in VBScript, you can use the MsgBox function, which allows you to specify particular buttons. For details, see the VBScript Reference.
You can also display information from client scripts directly on the page, intermingled with the HTML text.
To display information in the page from client scripts
<SCRIPT LANGUAGE="VBScript">
document.write "The current time is " & time
</SCRIPT>
If your page contains an HTML text box or text area control, you can change the contents of the box to display information.
To display information inside an HTML control
<SCRIPT LANGUAGE="VBScript">
Function btnShowTime_onclick()
document.Form1.txtTime.value = time
End Function
</SCRIPT>
If your application will be running in browsers that support Dynamic HTML (such as Microsoftฎ Internet Explorer 4.0), you can directly set the text of any tag that has a name or ID.
To set the text of a tag using DHTML
<HEAD>
<SCRIPT LANGUAGE="VBScript">
Function btnChangeText_onclick()
para1.innerText = "The new time is: " & time
End Function
</SCRIPT>
</HEAD>
<BODY>
<P ID=para1>This text will be replaced.</P>
<P><INPUT TYPE="button" NAME="btnChangeText" VALUE="Change text"></P>
</BODY>
To format the text you are displaying, you can include HTML tags, as in the following example:
<SCRIPT LANGUAGE="VBScript">
document.write "<P>The current time is <B>" & time & "</B></P>"
document.write "<P>The current date is <B>" & date & "</B></P>"
</SCRIPT>
If the information you want to display includes characters that are reserved in HTML such as < and > you cannot directly include them in the string to display.
To display reserved characters
<
or <
for the opening angle bracket (<):<SCRIPT LANGUAGE="VBSCRIPT">
document.write "<Click here>"
</SCRIPT>
To display information to a user from a server script, you usually make it part of the page that is sent to the browser.
To display information on a page from a server script
<% Response.Write "The current time on the server is " & Time %>
or
<% = "The current time on the server is " & Time %>
or
<SCRIPT RUNAT="SERVER">
block. You can easily include HTML tags this way, as in the following example:<BODY>
<H1>The Time Page</H1>
<% t = time %>
<P>
The current time at the server is <B><%=t%></B>
</P>
</BODY>
The server cannot directly display a message box, but a server script can create a client script that displays one.
To display a message box in a server script
<%if fError = True then%>
<SCRIPT Language="VBSCRIPT">
alert("An error occured on server.")
</SCRIPT>
<%End If%>
If the information you want to display includes characters that are reserved in HTML such as < and > you cannot include them in the string to display.
To display reserved characters
<%= Server.HTMLEncode("The paragraph tag: <P>") %>