He recortado las localidades para implementarlo aquí en este post.
Script provincias.php
Código PHP:
//Selección de Provincias
echo "<form action='' method='post' name='buscar_form'><input type='hidden' />";
echo "<tr><td height='30px'><font color='red'>Provincia </font></td><td align='left'>
<select name='provincia' class='texto' id='provincia' onChange='formar(this.options.selectedIndex);'>
<option value='9999999' selected>-
-- Elegir --</option>
<option value='Alava'>
Alava </option>
<option value='Albacete'>
Albacete </option>
<option value='Alicante'>
Alicante </option>
<option value='Almería'>
Almería </option>
<option value='Asturias'>
Asturias </option>
<option value='Avila'>
Avila </option>
<option value='Badajoz'>
Badajoz </option>
<option value='Balears (Illes)'>
Balears (Illes) </option>
<option value='Barcelona'>
Barcelona </option>
<option value='Burgos'>
Burgos </option>
<option value='Cáceres'>
Cáceres </option>
<option value='Cádiz'>
Cádiz </option>
<option value='Cantabria'>
Cantabria </option>
<option value='Castellón/Castelló'>
Castellón/Castelló </option>
<option value='Ceuta'>
Ceuta </option>
<option value='Ciudad Real'>
Ciudad Real </option>
<option value='Córdoba'>
Córdoba </option>
<option value='Coruña (A)'>
Coruña (A) </option>
<option value='Cuenca'>
Cuenca </option>
<option value='Girona'>
Girona </option>
<option value='Granada'>
Granada </option>
<option value='Guadalajara'>
Guadalajara </option>
<option value='Guipúzcoa'>
Guipúzcoa </option>
<option value='Huelva'>
Huelva </option>
<option value='Huesca'>
Huesca </option>
<option value='Jaén'>
Jaén </option>
<option value='León'>
León </option>
<option value='Lleida'>
Lleida </option>
<option value='Lugo'>
Lugo </option>
<option value='Madrid'>
Madrid </option>
<option value='Málaga'>
Málaga </option>
<option value='Melilla'>
Melilla </option>
<option value='Murcia'>
Murcia </option>
<option value='Navarra'>
Navarra </option>
<option value='Ourense'>
Ourense </option>
<option value='Palencia'>
Palencia </option>
<option value='Palmas (Las)'>
Palmas (Las) </option>
<option value='Pontevedra'>
Pontevedra </option>
<option value='Rioja (La)'>
Rioja (La) </option>
<option value='Salamanca'>
Salamanca </option>
<option value='Santa Cruz de Tenerife'>
Santa Cruz de Tenerife </option>
<option value='Segovia'>
Segovia </option>
<option value='Sevilla'>
Sevilla </option>
<option value='Soria'>
Soria </option>
<option value='Tarragona'>
Tarragona </option>
<option value='Teruel'>
Teruel </option>
<option value='Toledo'>
Toledo </option>
<option value='Valencia/València'>
Valencia/València </option>
<option value='Valladolid'>
Valladolid </option>
<option value='Vizcaya'>
Vizcaya </option>
<option value='Zamora'>
Zamora </option>
<option value='Zaragoza'>
Zaragoza </option>
</select></td></tr>";
echo "<tr><td height='30px'><font color='red'>Localidad </font></td><td align='left'>
<select name='localidad' class='texto' id='localidad'>
<option value='9999999' selected>-
-- Elegir --</option>
</select>
<script language='javascript'>
var num_departamentos = document.buscar_form.provincia.options.length;
var depart = new Array(num_departamentos);
var empleados = new Array(num_departamentos);
for (var i=0; i<num_departamentos; i++)
{
depart[i]= new Array();
empleados[i]= new Array();
}
depart[0][0] = new Option ('- Elegir ---','9999999');
depart[0][0] = new Option ('Todas','Todas');depart[1][1] = new Option ('Alegría-Dulantzi','Alegría-Dulantzi');depart[1][2] = new Option ('Amurrio','Amurrio');depart[1][3] = new Option ('Artziniega','Artziniega');depart[1][4] = new Option ('Ayala/Aiara','Ayala/Aiara');depart[1][5] = new Option ('Campezo/Kanpezu','Campezo/Kanpezu');
depart[0][0] = new Option ('-- Elegir ---','9999999')
function formar(x){
var temp=document.buscar_form.localidad;
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null;
for (i=0;i<depart[x].length;i++){
temp.options[i] = new Option(depart[x][i].text,depart[x][i].value);
}
temp.options[0].selected=true;
}
formar(document.buscar_form.provincia.options.selectedIndex);
</script></form></td></tr>";