Javascript plugin. How to search a database record

Hi all,

I work on a page wich intents to upload a list of codes just copy-paste in a multiline box, then a button to validate this codes and fill a RG

My problem is how to validate in a javascript action because I can reference the multiline text and split into a list of texts, but for each line I want to check if this text line already exist in a table.
I need to lookup the database for each text value in a java array.
I try with dynamic data and “search” but I don’t found how to send the java text variable and check the result in an “if”

How can I made a lookup to a database table for a single value?