pass html input textbox value to a javascript function - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

pass html input textbox value to a javascript function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <input type="text" id="myId">
      &nbsp; /* w  ww.jav  a  2 s.  c o  m*/
      <input type="button" 
             value="search" 
             class="p-userButton" 
             onClick="showTable(document.getElementById('myId').value);"> 
      <script type="text/javascript">
function showTable(val){
         console.log(val) ;
     }

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

Related Tutorials