Id should be unique, use a class instead.
<input class="path"/>
<input class="path"/>
$('.path').val("123");
And when you are setting a common value by using a class selector, there is no need to iterate.
solved for each element with this id jquery