Call PHP site from Javascript

I have three separate buttons in html. Each button is representing one form. I want to know how to execute a different php action=“phpfile.php” for each button press.

...
<form name="form1" action="php1.php" method="post">
        ...code
        <input type="button" name="php1" value="php1" onclick="php1()" />
</form>
<form name="form2" action="php2.php" method="post">
        ...code
        <input type="button" name="php2" value="php2" onclick="php2()" />
</form>
<form name="form3" action="php3.php" method="post">
        ...code
        <input type="button" name="php3" value="php3" onclick="php3()" />
</form>
...
<script type="text/javascript">
    function php1(){
        ...code
        [U][B][I][COLOR="#FF0000"]Call PHP site1?[/COLOR][/I][/B][/U]
    }

    function php2(){
        ...code
        [U][B][I][COLOR="#FF0000"]Call PHP site2?[/COLOR][/I][/B][/U]
    }

    function php3(){
        ...code
        [U][B][I][COLOR="#FF0000"]Call PHP site3?[/COLOR][/I][/B][/U]
    }

 </script>

If you want to submit the form data to a php script depending on which button was pressed then you don’t need 3 functions. You can do it with just 1 function. In the form’s onsubmit event handler just change the value of the form’s action attribute to the correct value for the pressed button before submitting the form.

I would like to use three separate forms instead of a Submit button. Is this possible?

You’re not making sense because of course you can have as many forms as you like, each with their own submit button to submit only the form the pressed button is in.

I had this problem once too, I originally solved it in JavaScript, but thats not really the right thing to do, either make multiple form one for each button with hidden fields (not recommended) or just when you submit to php1, include php2 and 3 and put them in classes or functions or whatever and check the value of the button to see which one was clicked and just run whichever function or class corresponds to that value.

Oh and like i said above, it is possible to use three different submit forms, just use hidden fields for the values you need.