How to update zoho creator record ( a look up field) through widgets - js api?

How to update zoho creator record ( a look up field) through widgets - js api?

Can I ask help how to update a record with a look up field from a widget using JS API? I get to fetch value of look up field using the code below. But I'm not sure how to update the record in creator when user selected a different option from the dropdown.

      fetchLookupData();
        var selectedLookupValue = tempHolderData["Units_look_up"].ID; 
        setTimeout(function() {
            $("#unitDropdown").val(selectedLookupValue);
        }, 1000); // Timeout to allow dropdown to populate

    function fetchLookupData() {
        var config = {
            reportName: "All_Units", // Replace with the report name
            criteria : "ID!=null",
            page : 1,
            pageSize : 10
        };

        ZOHO.CREATOR.init().then(function() {
            ZOHO.CREATOR.API.getAllRecords(config).then(function(response){
                var recordArr = response.data;
                for(var index in recordArr){
                    console.log(recordArr[index]);
                    var item = recordArr[index];
                    var option = document.createElement("option");
                    option.value = item.ID; 
                    option.textContent = item.Unit; 
                    document.getElementById("unitDropdown").appendChild(option);
                }
            }).catch(function(error) {
                console.error("Error fetching lookup data:", error);
            });
        });
    }


HTML  Code:

                <div class="form-row">
                    <label for="unitDropdown" class="form-label">Unit</label>
                    <select id="unitDropdown" name="unitDropdown" class="form-input">
                        <!-- Options will be dynamically populated here -->
                    </select>
                </div>