Checkbox Object

By: aathishankaran Viewed: 169 times  Printer Friendly Format    


The checkbox object is the form object that is best equipped to denote logical (true or false) data. It acts as a toggle switch that can be turned on or off either by the user or by your JavaScript code. To define a checkbox, use the following HTML syntax:

<INPUT TYPE="checkbox"[NAME="objectName"] [VALUE="value"] [CHECKED][onClick="methodName"]> [displayText] 

For example, the following checkbox allows users to specify their foreign language proficiencies: 

<input type=checkbox name="language"> I speak multiple languages.

Example

<Html>

<Head>

<Title>

Check box Example

</Title>

<Body>

<Hl>Example for CheckBox</Hl>

<H2>Click on the checkBox and find the status</H2>

<Hr>

<Form Name=form1>

<Center>

Server

<Input Type=CheckBox

Name=svr

onClick="

if (svr. checked)

{

alert('The status is true');

}

else

{

alert('The status is false');

}

“>

<Hr>

</Center>

</Form>

</Body>

</Html>

Output

If you check the checkbox

If you uncheck the checkbox

 



Most Viewed Articles (in JSP )

Latest Articles (in JSP)

Comment on this tutorial