Easy Tutorial
❮ Prop Style Paddingtop Prop Datetime Type ❯

form Attribute


Definition and Usage

The form attribute returns a reference to the form that contains the option.

This attribute returns a form object.

Syntax


Browser Support

All major browsers support the form attribute.


Example

This example returns the form ID of the selected option in the dropdown list:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function displayResult(){
    var x=document.getElementById("mySelect").form.id;
    alert(x);
}
</script>
</head>
<body>

<form id="form1">
Select your favorite fruit:
<select id="mySelect">
    <option>Apple</option>
    <option>Orange</option>
    <option>Pineapple</option>
    <option>Banana</option>
</select>
</form>
<button type="button" onclick="displayResult()">Display Form ID</button>
    
</body>
</html>

❮ Prop Style Paddingtop Prop Datetime Type ❯