-6

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 ;
    }
aaa
  • 23
  • 7
  • `java` =/= `javascript`. Removed tag. – tnw Jan 06 '15 at 19:58
  • What does it have to do with `java`? Java is not the same as JavaScript http://stackoverflow.com/questions/245062/whats-the-difference-between-javascript-and-java/245069#245069 – Pshemo Jan 06 '15 at 19:58
  • When Firebug tells you that you have a syntax error, it usually tells you what code triggered it. – Quentin Jan 06 '15 at 20:00
  • I think you should learn to debug on your own but you a refering to a `c` variable that doesn't exist in that line `f.appendChild(c);` – The_Black_Smurf Jan 06 '15 at 20:06
  • @The_Black_Smurf i'm aware of this mistake , i corrected it but still same error – aaa Jan 06 '15 at 20:12

1 Answers1

0

This declaration doesn't look correct:

function all() {

function Nickname() {

Did you really intend to declare Nickname() inside all()?