title: How to call a function from a button click in JSP
body: <p>I have the following function:</p>
  
  <pre><code>&lt;script&gt;
  function assign()
  {
  String val="";
  String val = document.form1.text1.value;
  System.out.println(val);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>i am trying to call the function in the button click as shown below:</p>
  
  <pre><code>  &lt;button type="button" onclick="assign()"&gt;Display&lt;/button&gt; 
  </code></pre>
  
  <p>When i click on the button nothing happens. I want the string value in the text box to be printed on the console.Please help</p>