Q:

How to make drop down menu reflect the form action in PHP and HTML?

I want to change the form action based on the input of the drop down menu in the html. 
For example - 
When I submit the form and select Volvo then the form should redirect all the input or action to the volvo.php
<form action= "*Depending on the input of the drop down menu*">
  <select name="cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="fiat" selected>Fiat</option>
    <option value="audi">Audi</option>
  </select>
  <br><br>
  <input type="submit">
</form>

Thanks!

A:

Although this is definitely not the preferred way of doing this - the best way would be to have only one php file where you would check the value and act accordingly - here goes how to achieve what you asked for (using jQuery as an example):
<form id="MyForm">
    <select id="cars" name="cars">
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="fiat" selected>Fiat</option>
        <option value="audi">Audi</option>
    </select>
    <br><br>
    <input id="submitButton" type="submit">
</form>

<script>
    $("#submitButton").click(function(e){
        e.preventDefault();
        $('#MyForm').attr('action', $('#cars').val()+".php").submit();

    });
</script>

