JSFiddle - React, Tailwind, and code Playground
by Mohamed Amer
HTML
<form>
<input name="file" value="1.xml">
<input name="title" id="title" value="Smith">
<input type="submit" id="copy-down" value="copy">
</form>
<form>
<input name="file" value="2.xml">
<input name="title" id="title" value="Anderson">
<input type="submit" id="copy-down" value="copy">
</form>
JavaScript
$(document).ready(function(){
$('form').on('submit', function(e){
e.preventDefault();
var GetNameAttr1 = $(this).find('input:nth-child(1)').attr('name');
var GetTitleValue1 = $(this).find('input:nth-child(1)').val();
var NextFormNameAttr1 = $(this).next('form').find('input:nth-child(1)').attr('name');
if(NextFormNameAttr1 == GetNameAttr1){
$(this).next('form').find('input:nth-child(1)').val(GetTitleValue1);
}
var GetNameAttr2 = $(this).find('input:nth-child(2)').attr('name');
var GetTitleValue2 = $(this).find('input:nth-child(2)').val();
var NextFormNameAttr2 = $(this).next('form').find('input:nth-child(2)').attr('name');
if(NextFormNameAttr2 == GetNameAttr2){
$(this).next('form').find('input:nth-child(2)').val(GetTitleValue2);
}
});
});