Pass value from one input field to another with java script

Hi ! In simple way we can pass value from one input field to another input field in simple way by using following example

<!DOCTYPE html> 
<html> 
<head> 
  <title>Passing Input Value</title> 
  <script> 
    function passValue() { 
      var input1Value = document.getElementById("input1").value; 
      document.getElementById("input2").value = input1Value; 
    } 
  </script> 
</head> 
<body> 
  <form> 
    <label for="input1">Input 1:</label> 
    <input type="text" id="input1" name="input1" onkeyup="passValue()"> 
 
    <label for="input2">Input 2:</label> 
    <input type="text" id="input2" name="input2"> 
  </form> 
</body> 

But I want to knew how can we pass value from one input field of dynamic created rows (with condition) to another input field of the dynamic generated rows