0
Hello, I need some idea of how to create a dynamic heritage of parent input values for children and grandchildren. Once the user enters the value in an input automatically it needs to be changed in the child items. based on an input attribute called "inherit" that receives the id of the input from which it will inherit the value.
The scheme I created is not right, it updates everyone.
$('input:text').change(function(){
var id = $(this).attr('id');
if (($(this).parent().find('input:text').attr('herdar')) == id) {
$(this).parent().find('input:text').val(id);
}
});
<div id="teste1">
<ul>
<li><input type="checkbox" value="00" checked="true"><input type="text" >teste
<ul>
<li> <input type="checkbox" value="01"><input type="text" >item pai
<ul>
<li><input type="checkbox" value="01"><input type="text" >item filho</li>
<li><input type="checkbox" value="01"><input type="text" >item filho</li>
</ul>
</li>
<li><input type="checkbox" value="04"><input type="text" >item irmão</li>
</ul>
</li>
</ul>
</div>
Could someone help me?
I did it with Jquery, but if anyone has a simpler and better idea it’s okay.