Return and display a database field (based on user input)

Hi Team,
I am trying to set up a dynamic quote based on user input. So want to run a look up on my connected dataset based on user input selections. Where column A of dataset would be the permutation of the user input (i.e. Quote Type), and column B the Quote Price. I want to return the Quote price and then display it (also wish to save this value in the form that gets submitted back to another dataset).
Code isn’t working well, I can get the concatenated “Quote Type” based on user selections - this is named ‘tagConcat’ in the code. But only get returned undefined currently. Have been looking at the documentation but not making any progress so assistance would be very helpful! Thanks in advance.

Site Page: https://editor.wix.com/html/editor/web/renderer/edit/2ad2e6ba-cd16-468a-a2f2-e20436e17e91?metaSiteId=30633f59-c0e1-4412-bbf5-4519620dd743&editorSessionId=946c99a7-0ecb-4d3d-9ab0-64b9545cbdf2&referralInfo=my-account

Code:
import wixData from ‘wix-data’
$w.onReady( function () {
});
export function dropdown1_change(event) {
let size = $w(“#dropdown1”).value
console.log(size);
}
export function checkboxGroup1_change(event) {
let reporttype = $w(“#checkboxGroup1”).value
console.log(reporttype);
let tagConcat = ${$w('#dropdown1').value} ${$w('#checkboxGroup1').value};
console.log(tagConcat);
wixData.query(“QuotePricing”)
.eq(“title”, “tagConcat”)
.find()
.then( (results) => {
let items = results.items;
let item = items[0];
let quotePrice = item.quotePrice;
console.log(quotePrice);
$w(“#text12”).value = “quotePrice”;

}
)
. catch ( (err) => {
let errorMsg = err;
console.log(errorMsg);
} );
}

First thing: Checkbox group’s value property is an array

So according to your goal (from what i understand):

So want to run a look up on my connected dataset based on user input selections. Where column A of dataset would be the permutation of the user input (i.e. Quote Type), and column B the Quote Price. I want to return the Quote price and then display it

The solution for querying the database according to the dropdown selection should be:

export function dropdown1_change(event) {
   wixData.query("QuotePricing")
   .eq("title", $w("#dropdown1").value)
   .find()
   .then( (results) => {
      let item = results.items[0];
      let quotePrice = item.quotePrice;
      console.log(quotePrice);
      $w("#text12").value = quotePrice;
   })
   .catch( (err) => {
      let errorMsg = err;
      console.log(errorMsg);
   });
}

The solution for querying the database according to the checkbox group should be:

export function checkboxGroup1_change(event) {
   wixData.query("QuotePricing")
   //.hasSome("title", $w("#checkboxGroup1").value) //(1)
   //.hasAll("title", $w("#checkboxGroup1").value) //(2)
   .find()
   .then( (results) => {
      let item = results.items[0];
      let quotePrice = item.quotePrice;
      console.log(quotePrice);
      $w("#text12").value = quotePrice;
   })
   .catch( (err) => {
      let errorMsg = err;
      console.log(errorMsg);
   });
}

See the difference between the two query function above and choose the one that suits best
(1) .hasSome()
(2) .hasAll()

Hi Shan,
Thanks for your help. Although I’m trying to query the database based on both the dropdown & the checkbox array which is then concatenated - Giving me the “tagconcat” value - this is the value that I want to then query the database with (in column A of the database) and return a result (column b) of the database.

I have reviewed my code and made some changes - but I still get the error "TypeError: Cannot read property ‘quotePrice’ of undefined. I don’t really understand as it seems to find the database collection “QuotePricing” okay, and the “tagconcat” value is coming out fine in the console.log.

Updated code as below:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixData from ‘wix-data’
$w.onReady( function () {
});
export function dropdown1_change(event) {
let size = $w(“#dropdown1”).value
console.log(size);
}
export function checkboxGroup1_change(event) {
let reporttype = $w(“#checkboxGroup1”).value
console.log(reporttype);
let tagConcat = ${$w('#dropdown1').value} ${$w('#checkboxGroup1').value};
console.log(tagConcat);
}

export function button2_click(event) {
//Add your code for this event here:
wixData.query(“QuotePricing”)
.eq(“title”, “tagconcat”)
.find()
.then( (results) => {
let item = results.items[0];
let quotePrice = item.quotePrice;
console.log(quotePrice);
}
)
. catch ( (err) => {
let errorMsg = err;
console.log(errorMsg);
} );
}

I spotted a mistake where I wrote “tagconcat” instead of “tagConcat”, no change on the outcome - still get the TypeError as above.