OK, OK, I'm being a bit obscure..
Here's a fix - untested, but on the right lines...
It uses Ajax (prototype) but it's really easy - if I can use it anyone can!
On top of your form page in the head area, put this:
<script src="path/to/prototype.js" type="text/javascript"></script>
<script src="path/to/myAjax.js" type="text/javascript"></script>
In your form (1st dropdown) do this (the values and labels should really be generated from the DB, because the values (4,8,10) should relate to mysql foreign keys for the second dropdown, but could be coded by hand:
<select id="myselect" name="myselect" onChange="getOptions();return false;">
<option value = "4">Wales</option>
<option value = "8">Scotland</option>
<option value = "10">Ireland</option>
</select>
The second dropdown (assuming default is Wales from dropdown 1):
<select id="myselect2" name="myselect2">
<option value = "1">Cardiff</option>
<option value = "7">Swansea</option>
<option value = "13">Aberystwyth</option>
</select>
Here's your custom function written in your myAjax.js file:
function getOptions(){
var sVal = $F('myselect');
var sContainer = 'myselect2';
var pars = "id=" + sVal;
var sURL = 'includes/get_options.inc.php'
var getAjax = new Ajax.Updater(sContainer,sURL,{method: 'post',parameters: pars});
}
Your php file for handling the request and posting back the data is as follows:
//(set your mysql connection details to $conn)
$id = addslashes(htmlentities($_POST['id']));
$sql = mysql_query("SELECT * FROM cities WHERE country = '{$id}'",$conn);
$output = "";
while($data = mysql_fetch_array($sql)){
$output = $output . "\n\t<option value=\"{$data['city_id']}\">{$data['city_name']}</option>"
}
echo $output;
You'll probably need to debug this as I typed it off the top of my head and haven't tried it out. Good luck.
By the way you can get the prototype library from the scriptaculous site.