Hey guys!
I need to make a search by State, City, and Specialty. I have tried a few codes I found without luck they don’t include the processing file or just don’t work. I just want a simple search that has those selections currently only California and Orange County cities. Can anyone point me in the direction of setting this code up? The template I am working with is HTML so I’m not sure if the outcome has to be an HTML file with each individual file per profile or I can set up something so I can use a PHP or JS file to help. It would be nice if the search result landed on a page with the profile pictures then to the HTML page of the profile that I can individually make since there coming in slowly.
I’m currently working with this for just getting the drop downs to work but I already messed it up trying to change it from Country, State, City
[php]/* This script and many more are available free online at
The JavaScript Source!! http://www.javascriptsource.com
Created by: Michael J. Damato | http://developing.damato.net/ */
// State lists
var states = new Array();
states[‘United States’] = new Array(‘California’,‘Florida’,‘New York’);
// City lists
var cities = new Array();
cities[‘United States’] = new Array();
cities[‘United States’][‘California’] = new Array(‘Aliso Viejo’, ‘Anaheim’, ‘Brea’, ‘Buena Park’, ‘Costa Mesa’, ‘Cypress’, ‘Dana Point’, ‘Fountain Valley’, ‘Fullerton’, ‘Garden Grove’, ‘Huntington Beach’, ‘Irvine’, ‘La Habra’, ‘La Palma’, ‘Laguna Beach’, ‘Laguna Hills’, ‘Laguna Niguel’, ‘Laguna Woods’, ‘Lake Forest’, ‘Los Alamitos’, ‘Mission Viejo’, ‘Newport Beach’, ‘Orange’, ‘Placentia’, ‘Rancho Santa Margarita’, ‘San Clemente’, ‘San Juan Capistrano’, ‘Santa Ana’, ‘Seal Beach’, ‘Stanton’, ‘Tustin’, ‘Villa Park’, ‘Westminster’, ‘Yorba Linda’);
var specialtys = new Array();
specialtys[‘United States’] = new Array();
specialtys[‘United States’][‘California’][‘Aliso Viejo’] = new Array(‘Law’, ‘Anaheim’, ‘Brea’, ‘Buena Park’, ‘Costa Mesa’, ‘Cypress’, ‘Dana Point’, ‘Fountain Valley’, ‘Fullerton’, ‘Garden Grove’, ‘Huntington Beach’, ‘Irvine’, ‘La Habra’, ‘La Palma’, ‘Laguna Beach’, ‘Laguna Hills’, ‘Laguna Niguel’, ‘Laguna Woods’, ‘Lake Forest’, ‘Los Alamitos’, ‘Mission Viejo’, ‘Newport Beach’, ‘Orange’, ‘Placentia’, ‘Rancho Santa Margarita’, ‘San Clemente’, ‘San Juan Capistrano’, ‘Santa Ana’, ‘Seal Beach’, ‘Stanton’, ‘Tustin’, ‘Villa Park’, ‘Westminster’, ‘Yorba Linda’);
function setStates() {
cntrySel = document.getElementById(‘country’);
stateList = states[cntrySel.value];
changeSelect(‘state’, stateList, stateList);
setCities();
}
function setCities() {
cntrySel = document.getElementById(‘country’);
stateSel = document.getElementById(‘state’);
cityList = cities[cntrySel.value][stateSel.value];
changeSelect(‘city’, cityList, cityList);
}
function setCities() {
cntrySel = document.getElementById(‘country’);
stateSel = document.getElementById(‘state’);
stateSel = document.getElementById(‘specialtys’);
cityList = cities[cntrySel.value][stateSel.value];
changeSelect(‘city’, cityList, cityList);
}
function changeSelect(fieldID, newOptions, newValues) {
selectField = document.getElementById(fieldID);
selectField.options.length = 0;
for (i=0; i<newOptions.length; i++) {
selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
}
}
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != ‘function’) {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
setStates();
});
[/php]
[php]
Make your selection
Country: | United States |
State: | Please select a Country |
City: | Please select a Country |
Specialty: | Please select a specialty |
</td>
</tr>
[/php]