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,
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;
});
}