根据第一个选择选项更改表单select optiosn?

时间:2015-06-12 09:38:26

标签: php jquery mysql

我有一个带有两个选择下拉列表的表单,但我想根据哪个类别与第一个选择下拉列表中的选项名称相等来更改第二个选择框。

<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>

1 个答案:

答案 0 :(得分:1)

所有内容都在这里解释:link