Javascript examples for DOM HTML Element:Input FileUpload
The form property returns a reference to the form containing the file upload button.
This property is read only.
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> <form id="myForm"> Select a file to upload: <input type="file" id="myFile"> </form>// w ww. java 2 s .c o m <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>