我如何根据下拉选项包含PHP?

时间:2017-03-17 01:09:25

标签: php html

我想根据下拉菜单选项显示php include。 但诀窍是我想在提交页面之前显示包含。

<?php include 'page.php'; ?>

<select name="s1"style="width: 70px;" >
          <optgroup label="My Input">
          <option value="">Select...</option>
          <option value="one kind</option>
          <option value="second kind</option>
</select>

如何在提交页面之前根据选择的选项显示我的页面?

1 个答案:

答案 0 :(得分:0)

我找到了它!

<!DOCTYPE html>
<html>
<body>

<p>Select a new car from the list.</p>

<select id="mySelect" onchange="myFunction()">
  <option value="Audi">Audi
  <option value="BMW">BMW
  <option value="Mercedes">Mercedes
  <option value="Volvo">Volvo
</select>

<p>When you select a new car, a function is triggered which outputs the value of the selected car.</p>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("mySelect").value;
    document.getElementById("demo").innerHTML = "You selected: " + x;
}
</script>

</body>
</html>