Set default to Input field type file - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Set default to Input field type file

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body>
       Name: //from  ww w .j a  v  a2 s  . c  o  m
      <input type="file" id="myText" value="old value"> 
      <button type="button" onclick="myFunction()">Try it</button> 
      <p id="demo"></p> 
      <script>
function myFunction() {
    var x = document.getElementById("myText").defaultValue="default.jpeg";
    document.getElementById("demo").innerHTML = x;
}

      </script>  
   </body>
</html>

Related Tutorials