I'm currently facing an issue with updating the value of an input field on a website using JavaScript.
Although I can successfully update the input field's value, I find that I am unable to trigger the autocomplete feature.
Interestingly, when I manually type into the input field, the autocomplete works as expected. However, my JavaScript code fails to trigger it.
I've experimented with various approaches such as .focus, .blur, and keyboard events but have had no success.
To tackle this challenge, I'm utilizing the CJS extension for Chrome which enables me to inject JavaScript into the AngularJS website's input field.
Upon clicking the input field, I set the value programmatically, yet the autocomplete doesn't trigger successfully.
https://material.angularjs.org/latest/demo/autocomplete
Here's a snippet of my code:
var focusedInput = null;
$('input').click(function(){
focusedInput = $(this);
focusedInput.focus();
simulateKeysPressed("North");
alert("Ohh Hey");
})
function simulateKeysPressed( inputData)
{
focusedInput.val(inputData);
focusedInput.blur();
}
Any assistance on resolving this issue would be greatly appreciated.