RhythmAddict112
Programmer
hey all..cFlava was nice enough to help me with an issue I had over in the JS forum. I needed a technique that would help me determine the values in drop box box B based on the selection from drop down box A. The code for this is below...The problem is, I need to populate the arrays with my values from my query.
My first drop down would be doing:
SELECT Locations, zone_id
FROM tbl_locations;
[will generate a max of 709 results]
and the 2nd drop down...
select locations
from tbl_locations
where zone_id = *zone_id_from_first_drop_down*
can anyone help me out on this?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html>
<head>
<title>new document</title>
<script language="javascript" type="text/javascript">
<!--
var array_0 = new Array('Jeep', 'VW', 'Ford');
var array_1 = new Array('Giants', 'Mets', 'Rangers');
var array_2 = new Array('Pizza', 'Ice Cream', 'Beer');
function build(which_array, which_field) {
var ary;
if (which_array != "") {
ary = eval('array_' + which_array);
which_field.options.length = 0;
for (var i = 0; i < ary.length; i++) {
which_field.options[which_field.options.length] = new Option( ary[i], ary[i]);
}
}
}
-->
</script>
</head>
<body>
<form name="f">
<select name="s1" onchange="build(this.options[this.selectedIndex].value, this.form.s2);">
<option value="" selected>Select One...</option>
<option value="0">Cars</option>
<option value="1">Teams</option>
<option value="2">Food</option>
</select>
<select name="s2">
</select>
</form>
</body>
</html>
My first drop down would be doing:
SELECT Locations, zone_id
FROM tbl_locations;
[will generate a max of 709 results]
and the 2nd drop down...
select locations
from tbl_locations
where zone_id = *zone_id_from_first_drop_down*
can anyone help me out on this?