I'll start with the code:
<input type="text" name="13939069" alt="2171">
<input type="text" name="2171">
Basically the name is the category ID, and when there is an alt value present, it is the id of the parent category.
What needs to happen is when the value of the parent category is changed the value of the child categories are also changed.