我的代码出现JavaScript错误

javascript error with my code

本文关键字:JavaScript 错误 代码 我的      更新时间:2023-09-26

我正在尝试构建一个复杂的自动表单填充器。我写了下面的代码,但是当我尝试在FireBug中运行它时,它一直说语法错误。

在此代码中,我

尝试在我正在填写的页面中创建一个弹出表单,根据需要创建用户名(函数a())。在函数Nickname()中,我正在获取我在函数a()中创建的用户,将其保存在数组中,随机选择一个用户名,在适当的位置填写,然后检查是否可以。功能传递和选中正在填写表单的其余部分。

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 ;
    }

此声明看起来不正确:

function all() {
function Nickname() {

你真的打算在all()内部宣布Nickname()吗?