| Property | Description |
|---|
| Action | It sets and returns the value of the action attribute in a form. |
| enctype | It sets and returns the value of the enctype attribute in a form. |
| Length | It returns the number of elements in a form. |
| Method | It sets and returns the value of the method attribute in a form that is GET or POST. |
| Name | It sets and returns the value of the name attribute in a form. |
| Target | It sets and returns the value of the target attribute in a form. |
| Property | Description |
|---|
| Name | It sets and returns the value of the name attribute of the hidden input field. |
| Type | It returns type of a form element. |
| Value | It sets or returns the value of the value attribute of the hidden input field. |
| Property | Description |
|---|
| defaultValue | It sets or returns the default value of a password field. |
| maxLength | It sets or returns the maximum number of characters allowed in a password filed. |
| Name | It sets or returns the value of the name attribute of a password field. |
| readOnly | It sets or returns whether a password fields is read only or not. |
| Size | It sets or returns the width of a password field. |
| Value | It sets or returns the value of the attribute of the password field. |
| Method | Description |
|---|
| select() | It selects the content of a password field. |
| Property | Description |
|---|
| Name | It sets or returns the name of the checkbox. |
| Type | It returns the value “check”. |
| Value | It sets or returns the value of the attribute of a checkbox. |
| checked | It sets or returns the checked state of a checkbox. |
| defaultChecked | It returns the default value of the checked attribute. |
| Method | Description |
|---|
| click() | It sets the checked property. |
| Collection | Description |
|---|
| options | It returns a collection of all the options in a dropdown list. |
| Property | Description |
|---|
| Length | It returns the number of options in a dropdown list. |
| selectedIndex | It sets or returns the index of the selected option in a dropdown list. |
| Type | It returns a type of form element. |
| name | It returns the name of the selection list. |
| Method | Description |
|---|
| add() | It adds an option to a dropdown list. |
| remove() | It removes an option from a dropdown list. |
| Property | Description |
|---|
| Index | It sets or returns the index position of an option in a dropdown list. |
| Text | It sets or returns the text of an option element. |
| defaultSelected | It determines whether the option is selected by default. |
| Value | It sets or returns the value to the server if the option was selected. |
| Prototype | It is used to create additional properties. |
| Methods | Description |
|---|
| blur() | It removes the focus from the option. |
| focus() | It gives the focus to the option. |
Example : Simple Program on Option Object Method
<html>
<head>
<script type="text/javascript">
function optionfruit(select)
{
var a = select.selectedIndex;
var fav = select.options[a].value;
if(a==0)
{
alert("Please select a fruit");
}
else
{
document.write("Your Favorite Fruit is <b>"+fav+".</b>");
}
}
</script>
</head>
<body>
<form>
List of Fruits:
<select name="fruit">
<option value="0">Select a Fruit</option>
<option value="Mango">Mango</option>
<option value="Apple">Apple</option>
<option value="Banana">Banana</option>
<option value="Strawberry">Strawberry</option>
<option value="Orange">Orange</option>
</select>
<input type="button" value="Select" onClick="optionfruit(this.form.fruit);">
</form>
</body>
</html>
| Property | Description |
|---|
| Checked | It sets or returns the checked state of a radio button. |
| defaultChecked | Returns the default value of the checked attribute. |
| Name | It sets or returns the value of the name attribute of a radio button. |
| Type | It returns the type of element which is radio button. |
| Value | It sets or returns the value of the radio button. |
| Method | Description |
|---|
| blur() | It takes the focus away from the radio button. |
| click() | It acts as if the user clicked the button. |
| focus() | It gives the focus to the radio button. |
| Property | Description |
|---|
| Value | It sets or returns the value of the text field. |
| defaultValue | It sets or returns the default value of a text field. |
| Name | It sets or returns the value of the name attribute of a text field. |
| maxLength | It sets or returns the maximum number of characters allowed in a text field. |
| readOnly | It sets or returns whether a text field is read-only or not. |
| Size | It sets or returns the width of a text field. |
| Type | It returns type of form element of a text field. |
| Property | Description |
|---|
| Value | It sets or returns the value of the text field. |
| defaultValue | It sets or returns the default value of a text field. |
| Name | It sets or returns the value of the name attribute of a text field. |
| Type | It returns type of form element of a text field. |
| Rows | It displays the number of rows in a text area. |
| Cols | It displays the number of columns in a text area. |