2012-03-14 54 views
0

我正在尝试创建单个选择题。JQuery Multiple Choice

在下面的例子中,我想选项1和3是正确的答案。当点击提交按钮时,我只想运行一个如果陈述,看是否选中了选项1和3复选框,如果是,则切换正确1 div。否则,如果选项1和3是而不是选中,则切换错误1 div。

头标记

我会

<script type="text/javascript"> 
    function toggleDiv2(divId) { 
    $("#"+divId).toggle("slow"); 
      } 
</script> 

然后在身体我将有:

<div class="control-group"> 

      <label class="control-label" for="optionsCheckboxList">Check your answers</label> 
      <div class="controls"> 
       <label class="checkbox"> 
       <input type="checkbox" id="option1" name="optionsCheckboxList1" value="option1"> 
       <strong>Option One</strong> this is a correct answer. Select this one. 
       </label> 
       <label class="checkbox"> 
       <input type="checkbox" id="option2" name="optionsCheckboxList2" value="option2"> 
       <strong>Option two</strong> this is an incorrect answer. Do not select this one. 
       </label> 
       <label class="checkbox"> 
       <input type="checkbox" id="option3" name="optionsCheckboxList3" value="option3"> 
       <strong>Option three</strong> This is a correct answer. Select this one. 
       </label> 
       <p class="help-block"><strong>Hint:</strong> Add a hint if you would like. This is optional.</p> 
      <br> 


     <a href="javascript:toggleDiv2('correct1');" class="btn btn-primary">Submit</a> 

      <br><br> 

      <div id="correct1" class="alert alert-success" style="display: none"> 
      Well Done! You correctly answered this question! 
      </div><!-- end correct1 --> 

      <div id="incorrect1" class="alert alert-error" style="display: none"> 
      Oh snap! Please try again. 
      </div><!-- end incorrect1 --> 
      </div><!-- end control-group --> 

不知道这是否事项或没有,但这是页面链接了jQuery于:

<script src="html/assets/js/jquery-ui-1_8_18custom/js/jquery-1.7.1.min.js" type="text/javascript"></script> 
<script src="html/assets/js/jquery-ui-1_8_18custom/js/jquery-ui-1.8.18.custom.min.js" type="text/javascript" ></script> 
+1

你有一个不必要的