Update the Text Input when any dropdown gets changed

I have two dropdowns and a textinput. dropdwon2 will be populated based on the selection in dropdown1. Input1 will change the value based on the selection in dropdown2 & dropdown2 . I chose textinput because I want users to change the value if they have to.

Everything works fine except, textinput value does not change when I change the value of dropdown1 for the very first time. When I change the dropdown1 for the first time, dropdown2 changes but textinput does not change the value, but it is enabled. However, if I change the selection in dropdown2 once and then changing dropdown1 would update textinput.

I am a newbie and I have written the following code with help of resources available online. There maybe better ways to accomplish what I want, however, it works fine except one problem which I explained.

I want, the textinput value changed when someone change selection in either of the dropdowns.

Thanks in advance.

import wixData from 'wix-data';
$w.onReady(function () {
    uniqueCatogory();
});
function uniqueCatogory() {
    wixData.query("itemDetails")
        .limit(1000)
        .find()
        .then(results => {
 const uniqueTitles = getUniqueTitles(results.items);
            $w("#dpdCategory").options = buildOptions(uniqueTitles);
        });
 function getUniqueTitles(items) {
 const titlesOnly = items.map(item => item.categoryName);
 return [...new Set(titlesOnly)];
    }
 function buildOptions(uniqueList) {
 return uniqueList.map(curr => {
 return { label: curr, value: curr };
        });
    }
}
export function dpdCategory_change(event, $w) {
    uniqueItemList();
    $w("#dpdItemlList").enable();
    price();
    $w("#iptPrice").enable();
}
function uniqueItemList() {
    wixData.query("itemDetails")
        .contains("categoryName", $w("#dpdCategory").value)
        .limit(1000)
        .find()
        .then(results => {
 const uniqueTitles = getUniqueTitles(results.items);
            $w("#dpdItemList").options = buildOptions(uniqueTitles);
        });
 function getUniqueTitles(items) {
 const titlesOnly = items.map(item => item.items);
 return [...new Set(titlesOnly)];
    }
 function buildOptions(uniqueList) {
 return uniqueList.map(curr => {
 return { label: curr, value: curr };
        });
    }
}
export function dpdItemList_change(event, $w) {
    price();
    $w("#iptPrice").enable();

}

function price() {
    wixData.query("itemDetails")
        .eq("item", $w('#dpdItemLit').value)
        .eq("categoryName", $w('#dpdCategory').value)
        .find()
        .then((results) => {
            $w('#iptPrice').value = results.items[0].price;
 //console.log(results.items);
        })
        .catch((err) => {
 let errorMsg = err;
        });
}