0

我的选择(下拉)框有问题...

问题是我有一组下拉菜单,每个下拉菜单都有一组下拉菜单..

在更改下拉列表时,所有子下拉列表都由更改的值选择


请帮我

以下代码具有下拉框

当父下拉列表更改时,所有子下拉列表将由该更改的值选择

     <table>
      <tr>
         <th>Parent DropDown</th>
        <th colspan="3">Child Dropdowns</th>
      </tr>
 <tr>
<td>
<select name="class_1" id="class_1">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_1" class="select_1">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_2" class="select_1">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_3" class="select_1">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
</tr>

<tr>
<td>
<select name="class_2" id="class_2">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_1" class="select_2">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_2" class="select_2">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_3" class="select_2">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
</tr>

<tr>
<td>
<select name="class_3" id="class_3">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_1" class="select_3">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_2" class="select_3">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
<td>
<select name="subClass_3" class="select_3">
<option value="First">First</option>
<option value="Second">Second</option>
</select>
</td>
</tr>
</table>
4

1 回答 1

0

据我了解,它是下拉菜单之间的父子关系。当父下拉列表的值改变时,子下拉列表中的值也应该改变。

这些场景经常出现在国家、州、城市选择中。

如果是这种情况,那么您需要处理下拉菜单的 onchange 事件。

$(element).change(function(){
    //coding for the same..................
});
于 2013-02-15T10:37:03.657 回答