I'm more of a Vanilla Javascript kind of guy, but the following should work.
//first one
<?php $a=0;?>
<?php for ($i=0;$i<5;$i++) {?>
<?php for ($j=0;$j<5;$j++) {?>
<input type="text" name="<?php echo 'post1['.$a.'][value1]'?>" id="valuex<?php echo $i.$j;?>" data-num="<?php echo $i.$j;?>" class="entryxy">
<?php $a++;?>
<?php }?>
<?php }?>
//second one
<?php $a=0;?>
<?php for ($i=0;$i<5;$i++) {?>
<?php for ($j=0;$j<5;$j++) {?>
<input type="text" name="<?php echo 'post2['.$a.'][value1]'?>" id="valuey<?php echo $i.$j;?>" data-num="<?php echo $i.$j;?>" class="entryxy">
<?php $a++;?>
<?php }?>
<?php }?>
<script>
window.onload = function(){
$(".entryxy").on("change",
function(){
// get data-number so we know which data set we need to modify
var sDataNum = this.getAttribute("data-num");
// get the value that needs to be set to opposing textbox
var sVal = this.value;
// determine if it is x or y that was changed
if(this.id.indexOf("valuex") > -1){
// Value of X changed
var eleY = $(("#valuey" + sDataNum))[0];
eleY.value = sVal;
}else{
// Value of Y changed
var eleX = $(("#valuex" + sDataNum))[0];
eleX.value = sVal;
}
}
);
};
</script>
A few things I changed:
- In order to allow for event listeners, I made it so all textboxes use a common class called "entryxy".
- I made "valuex##" and "valuey##" IDs instead of class names, thus allowing those elements to be accessed a little easier.
- I added in data attributes that help to quickly identify which set of data a textbox belongs. (That way we can reassign values where necessary.)
The actual jQuery and Javascript is in a script tag at the end of the PHP sections. I have not tested it yet, but I did comment it heavily, so at a minimum, it should definitely push you in the right direction. If anything in there does not make sense, please leave a comment and I will try to explain it a bit more.