Please help me solve it!

I’m a newbie, my data has too many item, but i dont know how i can collect or combine them, and my data sometime has 8, 9 item , if i write a code for 10 item, textbox will show nothing. Please help me fix more correct and shorter than i do. Thank you!

export function button14_click(event) {
        $w.onReady(function () { 

wixData.query("checklist")
  .hasAll("month", $w('#input1').value.toLocaleString())
  .find()
  .then( (results) => {
 if (results.items.length > 0)  {
 let totalCount = results.totalCount;
 let items = results.items;
 let item0 = items[0];
 let dd0 = item0.day;
 let mm0 = item0.month;
 let yy0 = item0.year;
 ...
 let item10  = items[10];
  let dd10 = item10.day;
 ...
  $w('#textBox1').value =...

Hey!

In your case, you can either use hasAll https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#hasAll or eq https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#eq to find the required value(s) in the dataset.

Please note that the last element of an array will have the following index array.length-1 and you need to refer to it like this array[array.length-1].

Therefore, if you want to refer to the 10th element, it’s index will be 9. You can check this link for a reference https://javadevnotes.com/java-array-length-examples

However, there is no need to create a variable for each item, you can either use repeaters https://www.wix.com/corvid/reference/$w.Repeater.html#forEachItem or a loop to make it easier.

thanks Anastasiia