My code worked perfectly on changed the value of input automatic on page load with a delay between it.
But there's another problem, When I tried to simulate pressing the [enter]
key on the input, it's no working, and it's submit the form and reload my page instead.
How I simulate pressing the [enter]
key in the input without submit the form and without reload my page? I am use pure javascript
without jQuery
This is my script :
var form = document.querySelectorAll("._k3t69");
var input = document.querySelectorAll("._7uiwk._qy55y");
var message = "Replacement..." ;
var maxMsg = 3 ;
var delay = 2.5 * 1000 ; // 2.5 Seconds
var j = 0, k = 0;
function setValue(){
if( j == maxMsg || j == input.length) {
clearInterval(looping)
} else {
input[j++].value = message ;
//And then simulate pressing enter key ON THE INPUT, not sumbit the form
form[k++].submit();
}
}
var looping = setInterval(setValue, delay);
<form class="_k3t69">
<input type="text" class="_7uiwk _qy55y">
</form>
<form class="_k3t69">
<input type="text" class="_7uiwk _qy55y">
</form>
<form class="_k3t69">
<input type="text" class="_7uiwk _qy55y">
</form>
Here's the fiddle