I have a huge <select> input that I call across many pages. My idea is to have this dropdown box as its own PHP file, and load it externally with JQuery. Is this even possible? Here’s an example of what I’m trying to do:
if ($variable) {
echo '<select>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>';
}
If I had to make changes to the dropdown, it would be quite frustrating to go through each page that it exists on and edit this dropdown. Is there a way to load it with JQuery?
Why not just store the dropdown contents in a variable in a separate php file and include the file in any script you need to use it? Let’s say
dropdown.phplooks like this:and then just do
wherever needed