on screen but when I click save the field value displayed on the form’s field is not saved so I think I’ve got to trigger a field change event on that field.?
const autosuggest = document.getElementById(“w3w-map”);
autosuggest.addEventListener(
“coordinates_changed”,
(ev,dt) => {
console.log(ev);
// alert(JSON.stringify(dt));
setTimeout(function(){
const searchInput = document.getElementById(“search-input”);
const inputValue = searchInput.value;
document.getElementById(“fielda6jMnn0r75”).value=inputValue;
},100);
// Get a reference to the input field
var fielda6jMnn0r75 = document.getElementById(“fielda6jMnn0r75”);
// Add an event listener for the change event
fielda6jMnn0r75.addEventListener(“change”, function() {
console.log(“Change event fired on fielda6jMnn0r75”);
});
// Set the new value for the input field
//var newValue = inputValue; //fielda6jMnn0r75.value = newValue;
// Create a new change event
var changeEvent = new Event(“change”, { bubbles: true });
// Dispatch the change event on the input field
fielda6jMnn0r75.dispatchEvent(changeEvent);
}
);
and I can see the change event firing but still the value is not written to the record.
autosuggest.addEventListener(“coordinates_changed”, (ev, dt) => {
console.log(ev);
// Delay the execution to ensure the value is updated after the event
setTimeout(function () {
const searchInput = document.getElementById(“search-input”);
const inputValue = searchInput.value;
// Update the value of the fielda6jMnn0r75 field
document.getElementById(“fielda6jMnn0r75”).value = inputValue;
// Create and dispatch a change event on the fielda6jMnn0r75 field
var changeEvent = new Event("change", { bubbles: true });
document.getElementById("fielda6jMnn0r75").dispatchEvent(changeEvent);
}, 100);