my app was created using React. By using dispatchEvent I am trying to prefill the form field value using JS. It is working fine in all browsers but not in IE 11.
IE console is showing object doesn't support error.
The code I have used to prefill the form field.
$(document.body).on('change', '#retailer', function() {
var retail_val = $(this).val();
//Storing the retailer value in the respective hidden text field.
if (retail_val != "0") {
var el = document.getElementById("text_6551650686371-InputField");
el.value = retail_val;
//calling the function
doEvent(el, 'input');
}
if (retail_val == "0") {
var el = document.getElementById("text_6551650686371-InputField");
el.value = "";
//calling the function
doEvent(el, 'input');
}
});
function doEvent(obj, event) {
event = new Event(event, {
target: obj,
bubbles: true
});
return obj ? obj.dispatchEvent(event) : false;
}
This is the error screenshot in IE 11 NOTE: I tried with .val() method, as my app was created using react it is not working. Please help me to pre-fill the form field value in IE also. Additionally when I change the tab the value in the field is going off.