[solved] How to Use Code to Let Your Users Search a Collection

Hello Charles,

In your collection, you have rpValue stored as a number and in your search you are comparing a number with a string which is why it is not returning anything.

To fix this change your search function from what you have to this:

export function search_click(event, $w) {
  wixData.query('NumberOfPartslists') 
  .eq('rpValue', parseInt($w('#input1').value)) // We use parseInt to turn string to integer
  .find()  
  .then(res => {     
    $w('#table2').rows = res.items; 
   });

Notice that I changed .contains to .eq, the reason for this is because a number can be 61 and the user inputs 6 and pulls all the rows that has the number 6 in it, I assume you want the exact number and in this case .eq is what you should use.

another change is the parseInt() wrapped around the input1.value which takes a string and parses it into an integer so you can compare it with the number type value in your collection.

Should be working perfectly after that.

Best,
Majd