use brackets in element name and call document.getElementsByName - Javascript DOM

Javascript examples for DOM:Document getElementsByName

Description

use brackets in element name and call document.getElementsByName

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function enableInput() {// w w w . j a  v a2s .  c  om
   console.log("aa");
   document.getElementsByName('user[135][name]')[0].disabled = false;
}

      </script> 
   </head> 
   <body> 
      <form name="myForm"> 
         <input size="15" name="user[135][name]" value="" disabled> 
      </form> 
      <input type="button" onclick="enableInput()" value="Enable">  
   </body>
</html>

Related Tutorials