Focus first textbox created using a FOR LOOP - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Focus first textbox created using a FOR LOOP

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from ww w. j  a  v a2  s .  c o  m*/
function defaultFocus(name) {
    document.getElementsByName(name)[0].focus();
}
defaultFocus('totalAmt');
    }

      </script> 
   </head> 
   <body> 
      <input type="text" id="totalAmt" name="totalAmt" size="10" value="0">  
   </body>
</html>

Related Tutorials