title: call javascript function on the click event of hyperlink
body: <p>I am developing a web application using JSP and Servlet.</p>
  
  <p>I am trying to call javascript function on the click event of hyperlink, and with that I am also passing some parameters to servlet using query string. </p>
  
  <pre><code>&lt;td&gt; &lt;a href="#?id=&lt;%=data[i][0]%&gt;&amp;protID=&lt;%=data[i][1]%&gt;&amp;seqNo=&lt;%=data[i][2]%&gt;" onclick="getValues();" &gt;Edit&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>javascript function:</p>
  
  <pre><code>&lt;script&gt;
  function getValues()
  {
      var url = document.URL;
      var planID = url.split("=");
      var pID = planID[1].split("&amp;");
  
      var remURI = url.split("&amp;");
      var protID = remURI[1].split("=");
  
      var s = remURI[2].split("=");
  
      document.getElementById('txtPlanID').value=pID[0];
      document.getElementById('txtProtID').value=protID[1];
      document.getElementById('txtSeqNo').value=s[1];
  
  //show("block");
  return false;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>But the problem is that I have to click twice on hyperlink to get desired result.
  I think onClick event is executing before sending query string.
  Please let me know if there is anything wrong in source code.</p>
  
  <p>Thanks in advance.....</p>