Search by State, City, and Specialty

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]

PS I do notice the typo of specialties :stuck_out_tongue:

Ive got something started this is going to take a lot of HTML pages but oh well. How can I make this not open in a new tab? I used the target="_blank" but that didn’t work. It works jumping page to page but that looks horrible.

HTML
[php]

California


Select City:



[/php]

PHP
[php]<?php
$xmlDoc=new DOMDocument();
$xmlDoc->load(“calinks.xml”);

$x=$xmlDoc->getElementsByTagName(‘link’);

//get the q parameter from URL
$q=$_GET[“q”];

//lookup all links from the xml file if length of q>0
if (strlen($q)>0) {
$hint="";
for($i=0; $i<($x->length); $i++) {
$y=$x->item($i)->getElementsByTagName(‘title’);
$z=$x->item($i)->getElementsByTagName(‘url’);
if ($y->item(0)->nodeType==1) {
//find a link matching the search text
if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) {
if ($hint=="") {
$hint="" .
$y->item(0)->childNodes->item(0)->nodeValue . “
”;
} else {
$hint=$hint . “
” .
$y->item(0)->childNodes->item(0)->nodeValue . “
”;
}
}
}
}
}

// Set output to “no suggestion” if no hint was found
// or to the correct values
if ($hint=="") {
$response=“no suggestion”;
} else {
$response=$hint;
}

//output the response
echo $response;
?> [/php]

XML
[php]<?xml version="1.0" encoding="utf-8"?>

Aliso Viejo./alisoviejo.html Anaheim./anaheim.html Brea./brea.html Buena Park./buenapark.html Costa Mesa./costamesa.html

[/php]

Anyone?

It needed to be ‘_self’

I was going to answer then didn’t see the topic anymore.

_blank means, open a new tab. It being empty would also work.

Sponsor our Newsletter | Privacy Policy | Terms of Service