Hi,
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:
Code HTML4Strict:<select id="Country" onChange="PoulateRegionsByCountryID"> <option></option> <option value="1">country1</option> <option value="2">country2..etc</option> </select> <select id="Region"> <option></option></select>
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.
Also I want all the related php code and JavaScript code with AJAX to be packaged together nicely.
Any ideas for this..?




Bookmarks