Manipulating Child tables with pagination

I tried to use


But I get Error

purchase_order__custom_js:3 Uncaught (in promise) ReferenceError: frm is not defined

My problem is that when I use


I get the correct length.
but if the items table is more than 50, the form is paginated and I get errors

The solution is to use the $.each()function as per the below post: