Access form and its element as array - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

Access form and its element as array

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
            function greeting(){/*  w  ww  .j a v  a2s  .c  o  m*/
                console.log("Welcome " + document.forms["frm1"]["fname"].value + "!")
            }
        
      </script> 
   </head> 
   <body>
       What is your name?
      <br> 
      <form name="frm1" action="submit.htm" onsubmit="greeting()"> 
         <input type="text" name="fname"> 
         <input type="submit" value="Submit"> 
      </form>  
   </body>
</html>

Related Tutorials