我有一个带有两个选择下拉列表的表单,但我想根据哪个类别与第一个选择下拉列表中的选项名称相等来更改第二个选择框。
<form id="search" action="/lawyer_search" method="get" class="clearfix">
<select name="perscorp" id="perscorp">
<option value="">Personal or Corporate</option>
<option value="1">Personal Law</option>
<option value="2">Corporate Law</option>
</select>
<select name="lawservice" id="lawservice">
<option value="">Select a service</option>
<?php $query="SELECT * FROM teamcat" ; $result=$ conn->query($query); while($row = $result->fetch_object()){ $checked = $row->teamCatName == $lawservice ? 'selected' : ''; echo "
<option value=\ "" . $row->teamCatID . "\"$checked>" . $row->teamCatName . "</option>\n"; } $result->free(); ?>
</select>
<input type="submit" id="search" class="search" name="search" value="Search" class="enquiry_btn" alt="Search" />
</form>