Calling PHP file from javascript : <p>I have an HTML form that calls a PHP function as:</p>

<pre><code>&lt;form action="test.php" method "get"&gt;
user data..
user data
&lt;/form&gt;
</code></pre>

<p>Now I want to change the functionality as:</p>

<pre><code> User enters 'yes' : Goto test1.php
 User enters 'no' : Goto test2.php
</code></pre>

<p>As this I could not find a way to directly achieve this via HTML. I called javascript from HTML as:</p>

<blockquote>
  <p>&lt;\input type ="button" onclick="myfunction()" value="submit"/></p>
</blockquote>

<p>In the <code>myfunction()</code> call,
I take inputs of the form using </p>

<blockquote>
  <p>var = document.getElementById('data').value</p>
</blockquote>

<p>Now Once user input is parsed. I want to take take all the form data and pass it to a PHP file like:</p>

<pre><code>if var==yes:
    action="test1.php" method="get"
if var==no:
    action="test2.php" method="get"
</code></pre>

<p>I have browsed through other answers which  suggest Ajax calls.
Can it be done without Ajax calls ?</p>
