Input FileUpload name Property - Change the name of a file upload button: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input FileUpload

Description

Input FileUpload name Property - Change the name of a file upload button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

A FileUpload object:
<input type="file" id="myFile" name="filename">

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<script>
function display() {
    var x = document.getElementById("myFile").name;
    console.log("The name of the file button is: " + x);
}

function change() {//from  www.jav a2  s  .co m
    var x = document.getElementById("myFile").name = "newFileName";
    console.log("The name was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials