在哪里添加<select>标签下的查询答案?</select>

时间:2013-11-24 07:20:38

标签: html login html-select account

我正在创建一个页面,其中我将填写帐户创建。其中一种形式是回答一个秘密问题。它在select标签中,然后问题在选项标签中。填写表格后,将出现一个提示框,供用户回答他/她选择的问题。如果输入正确的输入,则用户将成功登录。但如果不正确,则会失败登录。

我无法弄清楚我将把差异的答案放在哪里。输入中的问题,以便在输出的提示中键入正确答案时成功登录。这是我做的代码。请更正一下。


<HTML><HEAD><TITLE>Test Input</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function testResults (form) {
    var x = form.password.value=='Password';
    var y = form.username.value=='Username';
    var z =form.questions.value;
    prompt ("What is your secret answer?","Type your answer here");
    if (x&&y&&z)
    {
        alert("You are successfully Logged!");
    }
    else 
    {
        alert("You are unsuccessfully Logged!");
    }
}

</SCRIPT></HEAD><BODY>
    <FORM NAME="myform" METHOD="GET">Username<BR>
    <INPUT TYPE="text" NAME="username" VALUE="Username"><P>
    <FORM NAME="myform"  METHOD="GET">Password<BR>
    <INPUT TYPE="Password" NAME="password" VALUE="Password"><P>
   <form name="myform" method="get">
   Secret Question<BR>
   <select name="questions" size="1">
        <option value="one"> Where is your Birthplace?</p></option>
        <option value="two"> How old are you? </option>
        <option value="three"> What is your favorite show?</option>
    </select>

<INPUT TYPE="button" NAME="button" Value="submit" onClick=" testResults(this.form)">
</FORM>

</BODY>
</HTML>

1 个答案:

答案 0 :(得分:0)

看到这个小提琴:

http://jsfiddle.net/FqFLU/1/

var z =form.questions.value;
var ans=prompt ("What is your secret answer?","Type your answer here");
if (x&&y&&z==ans)
{
//Logged
}