Just several questions here
In case if i have a form, with structure like below
<form>
<div id='dynamicFormBox'>
<div id='parent_1'>
<div id='level_2'>
<div id='level_3'>
<input id='name' name='name' value=''/>
<input id='id' name='id' value=''/>
<input id='passNo' name='passNo' value=''/>
<input type="button" id="removeDiv"/>
</div>
</div>
</div>
<div id='parent_2'>
<div id='level_2'>
<div id='level_3'>
<input id='name' name='name' value=''/>
<input id='id' name='id' value=''/>
<input id='passNo' name='passNo' value=''/>
<input type="button" id="removeDiv"/>
</div>
</div>
</div>
<div id='parent_3'>
<div id='level_2'>
<div id='level_3'>
<input id='name' name='name' value=''/>
<input id='id' name='id' value=''/>
<input id='passNo' name='passNo' value=''/>
<input type="button" id="removeDiv"/>
</div>
</div>
</div>
</div>
</form>
So my questions here are
- How do i get to, say the input 'name' from either one of the parent? And in case if i input on the 'name', i can tell that the 'name' comes from that parent id and not other parent?
- How do i want to change, say input 'id' from all 3 parents, but with different value for each input 'id'?
- How do i make it so that if i change any of the input 'id', it will simultaneously changed the parent id too?
- If say i can add the parent div using append, how do i make it so that the id of the parent is changed according to the number of children inside the dynamicFormBox? Like right now, i have parent_1, parent_2 and parent_3, so if i append the next parent, the id will be automatically set to parent_4?
- How do i make it so that, only the 'parent' part of the parent id is following the value of the input 'id'? Like for parent_1, if i changed the value of input 'id' into 'john', then the parent id will change to 'john_1'?
- How do i make it so that, only the 'number' part of the parent id is following the value of the input 'passNo', and at the same time changing its number format? Like for example, for parent_2, if i changed the value of input 'passNo' into 2, then it will change the parent id into parent_02?
- For the delete button with id 'removeDiv', say if all button goes to the same removeDiv() function if i click it.. and i clicked the button inside parent_2, how can i make sure that it will delete only the parent_2 block, and not the others?
I know my some of my questions have already been answered in here, but i want to know for the case where all the inputs shared the same name and same id, i want to know how to differentiate which input in respect to their belonging parent.