The form
property gets the form that contains the textarea.
form |
Yes | Yes | Yes | Yes | Yes |
var v = textareaObject.form
A reference to the form element containing the textarea. If the textarea is not in a form, null is returned.
The following code shows how to get the id of the form containing the textarea.
<!DOCTYPE html>
<html>
<body>
<!--from w w w.j a v a 2s . c o m-->
<form id="myForm">
<textarea id="myTextarea" rows="4" cols="50">
this is a test
</textarea>
</form>
<button type="button" onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myTextarea").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: