Is it possible to use pure PHP to select different include_once 'template.php'"
from a dropdown menu?
In my head, it should be something like this:
<?php
Connections to db
Include libs etc
Include header.php
?>
<Form to select which include template.php to display>
<?php
Include dynamictemplate.php <- from form dropdown on select.
Include footer
?>
Or am I better off using AJAX or JS for this?
Yes, AJAX can Do it very very efficiently. Whether you want to bring the whole page or certain parts, it can be handled in a pretty elegent way through AJAX. if there is any specific questions please get back. (It is my favorite topic, or better still, tag me)
I found a way in PHP.
<form name="form1" method="POST" action="manage.php">
<select name="select" onChange="document.form1.submit()">
<option selected>Select a Table</option>
<option value="product">Product</option>
<option value="series">Series</option>
<option value="set">set<option>
</select>
</form>
<?php
if (isset($_POST['select']) && $_POST['select']) { } else { include
manage_product.php'; }
if (isset($_POST['select']) && $_POST['select'])
{
if ($_POST['select'] == 'product')
include 'manage_product.php';
if ($_POST['select'] == 'series')
include 'manage_series.php';
if ($_POST['select'] == 'set')
include 'manage_set.php';
} else {
return;
}
?>
however this leaves a blank option field on the bottom of the dropdown list, do not know why, this option links to product. And if you go back on the page it requires you to resend form info, which is slightly annoying. any tips on how to get rid of those?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.