I'm trying to build a sophisticated automatic form filler. I wrote the code below, but when I'm trying to run it in FireBug, it keeps saying syntax error.
In this code I am attempting to create a pop up form in the page I am filling, create usernames as demands (function a()
). In function Nickname()
, I'm getting the users I created in function a()
, save it in array, pick a username randomly, fill it out in the appropriate place, and check if it's okay or not. Function pass and checked is filling the rest of the form.
var f = document.createElement("form");
var i = document.createElement("input");
i.type = "text";
i.name = "username";
i.id = "username";
var ien = document.createElement("input");
ien.type = "number";
ien.name = "quantitye";
ien.id = "quantity";
var b = document.createElement("button");
b.onclick = "a()";
var bu = document.createElement("button");
bu.onclick = "bu()";
f.appendChild(i);
f.appendChild(ien);
f.appendChild(b);
f.appendChild(bu);
document.getElementsByTagName('body')[0].appendChild(f);
function a() {
var text = document.getElementById("username").value ;
var i;
var j ;
j = document.getElementById("quantity").value;
var text1 = "";
for(i = 1; i < j ; i++) {
text1+= text + i + " " ;
}
document.write(text1);
}
function Nickname() {
var array =[];
var Guser;
Guser = a();
array = Guser.split(',');
var length = array.length;
var randome = array[math.floor(math.random() * array.length)];
var index = array.indexOf(randome);
document.getElementById("nick").value = randome;
var r = confirm("Is It Okay To Continue ?");
if ( r == true ) {
if(index>-1 && length > -1) {
array.splice(index,1);
}
else if( r != true ) {
randome = array[math.floor(math.random() * array.length)];
document.getElementById("nick").value = randome;
var s = confirm("Is It Okay To Continue ?");
while ( s != true ) {
randome = array[math.floor(math.random() * array.length)];
document.getElementById("nick").value = randome;
}
}
}
}
function pass() {
var password = "123456789m";
document.getElementById("password").value = password;
document.getElementById("pass_conf").value = password;
}
function checked() {
var checked = true ;
document.getElementById(agd).checked = true ;
}