Hi,
I have an HTML dropdown menu:
<select id="team" name="team">
<option value="GBR">Great Britain</option>
<option value="USA">United States of America</option>
<option value="CAN">Canada</option>
</select>
I also have a second dropdown menu which has values generated from the following SQL:
<?php
$res = sqlsrv_query(
$conn,
"SELECT ID, Country, ISOCode FROM Country WHERE ISOCode = ?" // dynamically get value from team dropdown menu each time
);
while($row = sqlsrv_fetch_array($res)) { ?>
<option value="<?php echo $row['ID']; ?>"><?php echo $row['ID']; ?></option>
<?php
}
?>
What I’d like to do is every time I change the Team dropdown selection, it auto updates the 2nd Dropdown based on the Country abbreviation in the Team dropdown.
So each time I change the Country in the Team dropdown, a whole new set of SQL results appear in the 2nd dropdown.
Can someone show me how this would be done?
I presume I would be using some AJAX but I’m not totally sure where to begin with this.
On the site I’m building I am using jQuery.
Many thanks for any pointers.