Hello, I need some idea how to create a dynamic inheritance of values from a parent input to the children and grandchildren input. Once the user types the value into an input it automatically needs to be changed in the child items. based on an input attribute called "inherit" that receives the input id from which it will inherit the value.
The schema that I created is not right, it updates all.
$('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 anyone help me?
I've done it with Jquery, but if someone has a simpler and better idea, that's fine.