Javascript 填空题和多项选择题

Javascript 填空题和多项选择题,javascript,Javascript,我想知道是否有人能帮我?在我下面的代码中,如果问题2的答案可以按任意顺序排列,会怎么样?例如:臀部、身体、膝盖或膝盖、臀部、身体等。我应该如何修改我的代码?有人吗 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:la

我想知道是否有人能帮我?在我下面的代码中,如果问题2的答案可以按任意顺序排列,会怎么样?例如:臀部、身体、膝盖或膝盖、臀部、身体等。我应该如何修改我的代码?有人吗

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Quiz</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript">
var answer_list = [
    ['False'],
    ['body,hips,knees']

// Note: No comma after final entry
];

var response = [];

function getCheckedValue(radioObj) {
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}

function setAnswer(question, answer) {
    response[question] = answer;
}

function CheckAnswers() {
    var correct = 0;
    var resp, answ;
    for (var i = 0; i < answer_list.length; i++) {
        resp = response[i].toString();
        resp = resp.toLowerCase();
        answ = answer_list[i].toString();
        answ = answ.toLowerCase();
//#################################################################################################
        if (resp == answ) {
            correct++;
            if(i==0){
                document.forms[0].a1c.style.backgroundImage="url('correct.gif')";
                document.forms[0].a1c.value = "";
            }
            else{
                document.forms[0].a1d.style.backgroundImage="url('correct.gif')";
                document.forms[0].a1d.value = "";
            }
        }
        else{
            if(i==0){
                document.forms[0].a1c.style.backgroundImage = "url('incorrect.gif')";
                document.forms[0].a1c.value = " ANS: False. Position the head snugly against the top bar of the frame and then bring the foot board to the infant's feet.";
            }
            else{
                document.forms[0].a1d.style.backgroundImage = "url('incorrect.gif')";
                document.forms[0].a1d.value = " ANS: " + answ;
            }
//###################################################################################################
        }
    }
    document.writeln("You got " + correct + " of " + answer_list.length + " questions correct!");
}
</script>
</head>
<body>
<form action="" method="post">
<div>
<b>1. When measuring height/length of a child who cannot securely stand, place the infant such that his or her feet are flat against the foot board.</b><br />
<label><input type="radio" name="question0" value="True" />True</label>
<label><input type="radio" name="question0" value="False" />False</label>
<br />
<textarea rows="2" cols="85" name="a1c" style="background-repeat:no-repeat"></textarea>
<br />
<b>2. When taking a supine length measurement, straighten the infant's
<input type="text" name="question1_a" size="10" />, 
<input type="text" name="question1_b" size="10" />, and 
<input type="text" name="question1_c" size="10" />.</b>
<br />
<textarea rows="2" cols="85" name="a1d" style="background-repeat:no-repeat"></textarea>
<br />
<input type="button" name="check" value="Check Answers" onclick="setAnswer(0,getCheckedValue(document.forms[0].question0));setAnswer(1,[document.forms[0].question1_a.value,document.forms[0].question1_b.value,document.forms[0].question1_c.value]);CheckAnswers();" />
</div>
</form>
</body>
</html>

测验
变量答案列表=[
['False'],
[“身体、臀部、膝盖”]
//注:最后一项后无逗号
];
var响应=[];
函数getCheckedValue(radioObj){
如果(!radioObj)
返回“”;
var radioLength=radioObj.长度;
如果(放射长度==未定义)
如果(无线电目标检查)
返回radioObj.value;
其他的
返回“”;
对于(var i=0;i
真的
假的


2.测量仰卧位长度时,伸直婴儿的身体 , ,及 .


IMO最简单的方法是对用户的答案进行排序,并在CheckAnswers()中对正确答案进行排序