简体   繁体   English

警报框未显示,代码内出现问题,而不是浏览器

[英]ALERT Box not showing up, issue within code, not browser

I've currently created this code to check for an array (For the Login) before moving to the next array to corroborate the password. 我目前已创建此代码,以便在移至下一个数组以确认密码之前检查数组(用于登录)。 For some reason, there's a specific instance within the code preventing a javascript prompt or alert box from popping up. 由于某种原因,代码中存在一个特定的实例,可防止弹出JavaScript提示或警报框。 I've done trial and error and it appears to be an issue with the while statement overall. 我做了反复试验,这似乎与while语句有关。 But, further testing is not revealing anything obvious. 但是,进一步的测试并未发现任何明显的东西。

while(loginSelection != true)
{
    alert("Welcome to the Ballot Design Process");
    var loginUsername = prompt("Please enter in your username: ");

        for(checkFor; checkFor <= userID.length; checkFor++)
        {
            if(loginID == userID(count))
            {   
                if(user_password == password(checkFor)
                {
                    loginPassword = prompt("Please enter in your password: ");
                }
            }
            else
            {
                arrayPos += 1;

                if(arrayPos == userID.length-1)
                    alert("Sorry, you did not enter a correct identification.");
            }
        }

}

You are missing a closing bracket on your if statement: 您在if语句中缺少右括号:

 if(user_password == password(checkFor)) <<<<<

I recommend checking your javascript code with something like http://www.jshint.com if your debugger/IDE isnt picking it up. 如果您的调试器/ IDE不支持,建议您使用http://www.jshint.com之类的代码检查JavaScript代码。

以为你的意思是:

if (loginID == userID(checkFor))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM