Select a form action depending on the option chosen from a select tag
<p>I'm very new to this, so this may not the best way to go about solving this problem. Basically, I am trying to run one of three .php files upon a form submit. Which .php file I run should depend on what value the user chooses from the select field with id="periodDisplay". Would really appreciate some help.</p>

<pre><code>&lt;script&gt;

    function onSubmitForm(){

    if(document.getElementById("periodDisplayed").selectedIndex == 'This Week')
    {
        return document.selectDisplay.action ="thisWeek.php";
    }

    else if(document.getElementById("periodDisplayed").selectedIndex == 'This Month')
    {
        return document.selectDisplay.action ="thisMonth.php";
    }

    else if(document.getElementById("periodDisplayed").selectedIndex == 'All Workouts')
    {
            return document.selectDisplay.action ="allWorkouts.php";
    }

    else
    {
        return document.selectDisplay.action = "index.html";
    }
return true;
    }
&lt;/script&gt;




&lt;form id="selectDisplay" onsubmit="return onSubmitForm();"&gt;
    I want to see 
    &lt;select id="unitDisplayed"&gt;
        &lt;option&gt;Distance&lt;/option&gt;
        &lt;option&gt;Time&lt;/option&gt;
    &lt;/select&gt;
     for 
    &lt;select id="periodDisplayed"&gt;
        &lt;option&gt;This Week&lt;/option&gt;
        &lt;option&gt;This Month&lt;/option&gt;
        &lt;option&gt;All Workouts&lt;/option&gt;
    &lt;/select&gt;

    &lt;input type="submit"&gt;&lt;/input&gt;
&lt;/form&gt;
</code></pre>
