Then I have a simple program to change the value of the input field every time you blur it. It logs the values already used in an array, I check to use that array to check whether it has been used. It works in practically, but after some efforts it will return the truth, but still the value will not change.
Update code:
Verde defectualue = ['Freddy the Grosser', 'Jack the Fiddler', 'Ken the Sheep Header' 'Arnold the fish manger', 'Luke Car Salesman', 'Josh the Taylor', 'Carole the Becker', 'Thira the Nacho Vendor', 'example@email.com', 'Your message is here.']; Var log = new array (); // Create new array to enter the used index function set () {var newval = dftvalue [Math.floor (Math.random (* * 7)]; If (log in. Indexof (newval) == -1) {this.value = newval; Logused.push (newVal); Console.log (logused); } And if (log in. Indexof (newval)> = 0) {setdftvalue (); } If (log in length == 8) {for (i = 0; i & lt; = 7; i ++) {logged in.pop (); }}} Document.getElementById ('formname'). Onblur = setdftvalue;
JSFIDDLE
your approach It is unnecessarily complex, at high level, I recommend an approach which is more like this:
In this way you will not need to use any recurring and call unnecessary functions. And there will be only one time to make you random, when you have used all your available names.
Here's an example:
Basic Answer
After some inventions, your work log in
Array will be filled, which will not do anything by calling it again. Actually, worse than nothing - it will call itself without any end.
No comments:
Post a Comment