The read only form
property returns a reference to the form containing the file upload button.
form |
Yes | Yes | Yes | Yes | Yes |
var v = fileuploadObject.form
A reference to the form element containing the file upload button. If the file upload button is not in a form, null is returned.
The following code shows how to get the id of the form containing the <input type="file"> element.
<!DOCTYPE html>
<html>
<body>
<!--from w w w .ja v a 2 s.co m-->
<form id="myForm">
Select a file to upload:
<input type="file" id="myFile">
</form>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myFile").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: