我对此很陌生,所以这可能不是解决这个问题的最佳方法。基本上,我试图在提交表单时运行三个 .php 文件之一。我运行哪个 .php 文件应该取决于用户从 id="periodDisplay" 的选择字段中选择的值。非常感谢一些帮助。
<script>
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;
}
</script>
<form id="selectDisplay" onsubmit="return onSubmitForm();">
I want to see
<select id="unitDisplayed">
<option>Distance</option>
<option>Time</option>
</select>
for
<select id="periodDisplayed">
<option>This Week</option>
<option>This Month</option>
<option>All Workouts</option>
</select>
<input type="submit"></input>
</form>