Sending POST through function in javascript
<p>I'm using the following code to send POST request if validation passes. But it doesn't. Can someone show me a wway to make it work.</p>

<pre><code>&lt;script type="text/javascript"&gt;

    function go()
    {
    var username = document.form.name.value;
    var pwd = document.form.pwd.value;
    if (username == '') {
      var oldHTML = document.getElementById('myAnchor').innerHTML="Please fill out username.";
    var newHTML = "&lt;span style='color:red'&gt;" + oldHTML + "&lt;/span&gt;";
    document.getElementById('myAnchor').innerHTML = newHTML;
    }
    if (pwd == '') {
      var oldHTML = document.getElementById('myAnchor2').innerHTML="Please fill out password.";
    var newHTML = "&lt;span style='color:red'&gt;" + oldHTML + "&lt;/span&gt;";
    document.getElementById('myAnchor2').innerHTML = newHTML;
    }
      else {
       document.form.method="POST";
       document.form.action = "data.php";
    }
    &lt;/script&gt;
</code></pre>
