Reputation: 1
I am trying to fill the first text input from this google docs with an email: https://docs.google.com/forms/d/1ciJJg43i1tB9XhKMjFGZBteQFkH80nvyF1w4EpO7v_c/viewform?edit_requested=true
My code is:
window.onload = function() {
var input = document.getElementsByClassName("quantumWizTextinputPaperinputInput")[0];
input.focus();
input.click();
input.value = "[email protected]"
}
It actually replaces the email, but the grey text that is initially in the input (e.g. "enter your email here") does not disappear. And if I don't manually click the label, google doesn't recognize that there is an input there.
I tried to simulate a click but didn't find a working code. Can someone help me?
Upvotes: 0
Views: 638
Reputation: 89139
You can trigger an input event.
var input = document.getElementsByClassName("quantumWizTextinputPaperinputInput")[0];
input.value = "[email protected]"
input.dispatchEvent(new Event('input', {bubbles:true}))
Upvotes: 1