Create a simple query

I am looking to create a simple query,
Example when writing in an input the employee code (ID Solicitud)already registered in a database name=(Solicitud de Servicios) I want the name to appear in another input that I have on the same page and the amount in another input that I have on the same page.

Searching and I found many tutorials but they only show information in a table and I only want it to show me the result in the inputs.

I am using this code but it does not work for me.


import wixData from "wix-data";

$w.onReady(function () {   });

export function button1_click_1(event) {xxx()}

function xxx (parameter) {
    wixData.query("Solicitud de Servicios")
    .eq("id" ,$w('#input18').value)
    .find()
    .then( (results) => {
 if(results.items.length > 0) {
 let firstItem = results.items[0]; 

        $w('#input4').value = results.items
 

        } else {
 // handle case where no matching items found
        }
    } )
    .catch( (err) => {
 let errorMsg = err;
    } );
}

Hello there,

If I understood correctly you want the results of the items from your content collection to be displayed on your user inputs. If this is the case, instead of

$w('#input4').value = results.items

You’ll need to replace value with the placeholder property.

$w('#input4').placeholder = results.items

If this is not what you were referring to can you provide us with a little more info on what you mean by showing the results in the input.

Best regards,

My intention is that when writing the request id that my database has in input 18, it will automatically fill in all the fields on the page.

https://editor.wix.com/html/editor/web/renderer/edit/fcf9f205-fd09-466d-8445-73d920f92266?metaSiteId=34086ea9-9f09-4ee7-88a5-713525d7b8a6&editorSessionId=e748c7c8-c52a-4867-a966-0c6c7aa5e844&referralInfo=my-account

I already solved it, the code I used was the following.


import wixData from 'wix-data';



export function button1_click(event) {
      wixData.query("multiStepRegistrationForm") 
  .eq("id", $w('#input18').value) 
  .find() 
  .then( (results) => { 
     $w('#input4').value = results.items[0].firstName; 
   });
}