Professional Documents
Culture Documents
text: The text attribute sets the color for all the text on the page except
the text enclosed in an anchor <a> container and text that is under the
influence of a style that specifies color.
Example: < body background=name.jpg text=#FFFF00>
link: specifies the color of all the hyperlinks the user has not yet followed.
vlink: specifies the color of all the links the user has already followed or
visited at one time or another and that are kept in the browsers history.
i)
<html>
<body>
(a+b)<sup>2</sup>=a<sup>2</sup>+2ab+b<sup>2</sup><br>
</body>
</html>
ii)
<html>
<body>
H<sub>2</sub>+SO<sub>4</sub>=H<sub>2</sub>SO<sub>4</sub
>
</body>
</html>
iii)
<html>
<body>
A speed limit of <del>45</del>
<ins>55</ins>miles per hour.
</body>
</html>
JavaScript can put dynamic text into an HTML page - A JavaScript statement like
this: document.write("<h1>" + name + "</h1>") can write a variable text into an
HTML page
JavaScript can react to events - A JavaScript can be set to execute when something
happens, like when a page has finished loading or when a user clicks on an HTML
element
JavaScript can read and write HTML elements - A JavaScript can read and change
the content of an HTML element
JavaScript can be used to validate data - A JavaScript can be used to validate form
data before it is submitted to a server. This saves the server from extra processing
JavaScript can be used to detect the visitor's browser - A JavaScript can be used to
detect the visitor's browser, and - depending on the browser - load another page
specifically designed for that browser
JavaScript can be used to create cookies - A JavaScript can be used to store and
retrieve information on the visitor's computer
Confirm Box
A confirm box is often used if you want the user to verify or accept something.
When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.
If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
Syntax:
confirm("sometext");
Prompt Box
A prompt box is often used if you want the user to input a value before entering a page.
When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed
after entering an input value.
If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box
returns null.
Syntax:
prompt("sometext","defaultvalue");
VBScript Variables
Variable is a named memory location used to hold a value that can be changed during the
script execution. VBScript has only ONE fundamental data type, Variant.
Rules for Declaring Variables:
Variable Name must begin with an alphabet.
Variable names cannot exceed 255 characters.
Variables Should NOT contain a period (.)
Variable Names should be unique in the declared context.
Declaring Variables
Variables are declared using dim keyword. Since there is only ONE fundamental data type,
all the declared variables are variant by default. Hence, a user NEED NOT mention the type
of data during declaration.
Example 1: In this Example, Int Value can be used as a String, Integer or even arrays.
Dim Var
Example 2: Two or more declarations are separated by comma(,)
Dim Variable1,Variable2
10. Define with example: a) onclick () b) onchange (), c)OnSubmit, d) OnMouseOver
and OnMouseOut.
OnClick-Every element on a web page has certain events which can trigger JavaScript
functions.
For example, we can use the on Click event of a button element to indicate that a function
will run when a user clicks on the button. We define the events in the HTML tags.
<html>
<head>
<script type="text/javascript">
function sayHello()
{
alert("Hello World")
}
</script>
</head>
<body>
<input type="button" onclick="sayHello()" value="Say Hello" />
</body>
</html>
OnChange
onChange events are often used in combination with validation of form fields.
Below is an example of how to use the onChange event. The checkEmail() function will be
called whenever the user changes the content of the field:
<html>
<head>
<script type="text/javascript">
function sayHello()
{
alert("Hello World")
}
</script>
</head>
<body>
<input type="text" size="30" id="email" onchange="checkEmail()">
</body>
</html>
OnSubmit:
The onSubmit event is used to validate ALL form fields before submitting it.
Below is an example of how to use the onSubmit event. The checkForm() function will be
called when the user clicks the submit button in the form. If the field values are not accepted,
the submit should be cancelled. The function checkForm() returns either true or false. If it
returns true the form will be submitted, otherwise the submit will be cancelled:
<form method="post" action="abc.htm" onsubmit="return checkForm()">
OnMouseOver and OnMouseOut:
onMouseOver and onMouseOut are often used to create "animated" buttons.
Below is an example of an onMouseOver event. An alert box appears when an onMouseOver
event is detected:
<a href="http://www.schools.com"onmouseover="alert('An onMouseOver event');return
false">
<img src="schools.gif" width="100" height="30"></a>
When a browser requests an HTML file, the server returns the file
When a browser requests an ASP file, IIS passes the request to the ASP engine. The
ASP engine reads the ASP file, line by line, and executes the scripts in the file.
Finally, the ASP file is returned to the browser as plain HTML
Example:
<html>
<body>
<%response.write("This is my first VBScript")%>
</body>
</html>
Text fields are one line areas that allow the user to input text.
Settings:
Below is a listing of valid settings for text fields:
HTML
EXPLANATION
EXAMPLE
text
size=
maxlength=
name=
value=
align=
tabindex=
Size: The size option defines the width of the field. That is how many visible characters it can
contain.
Maxlength: The maxlength option defines the maximum length of the field. That is how
many characters can be entered in the field.
If you do not specify a maxlength, the visitor can easily enter more characters than are visible
in the field at one time.
Name: The name setting adds an internal name to the field so the program that handles the
form can identify the fields.
Value: The value setting defines what will appear in the box as the default value.
Align: The align setting defines how the field is aligned.
Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, The alignments are explained in
the image section.
Tabindex: The tabindex setting defines in which order the different fields should be
activated when the visitor clicks the tab key.
AN EXAMPLE:
Look at this HTML example:
<html>
<head>
<title>My Page</title>
</head>
<body>
<form name="myform" action="http://www.domain.com/myformhandler.php"
method="POST">
<div align="center"><br>
<input type="text" size="25" value="Enter your name here!"><br>
</div>
</form>
</body>
</html>
Username:
Password:
Log In