Reusable country/region select function
I am in the process of making a reusable country/region select function.
That is, the country select list is populated by default with countries and the regions select list is filled with the regions for that country when selecting a country. The data fetch is done by a AJAX call (using JSON format).
The basic html is something like this:
<select id="Country" onChange="PoulateRegionsByCountryID">
Now, I have no problem making it "work", however I am struggling
as to find the best approach for this to be reusable and flexible.
I want to be able to insert this function in any given php form.
I thought of using an include :
<?php include ("CountryRegionSelector.php") ?>
in the correct place in the form markup code, but this would not suffice for templates engines for example.
Any ideas for this..?