Вопрос

I have a problem with select (Dropdown) box...

the problem is i have a set of dropdowns and every dropdown having a set of dropdowns ..

While change a dropdown then all child dropdowns are selected by changed values


please help me

The following code having dropdown boxes

When a parent dropdown change then all child dropdowns will selected by that changed value

     <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>
Это было полезно?

Решение

As far as I understand it's parent child relationship between dropdowns. when the value of parent dropdown is changed, accrodingly the values in child dropdown should also get changed.

These scenario is often found in Country,State,City selection.

If this is the case then you need to handle onchange event for dropdown.

$(element).change(function(){
    //coding for the same..................
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top