无法使用淘汰赛Js使无线电正常工作

时间:2014-02-01 14:27:30

标签: javascript knockout.js radio-button

我正在尝试创建一个测验,用户可以输入自己的问题和多项选择答案。

这是我的HTML

<form>
    <div>
        <label>Quiz Name</label>
        <input type="text" id="quizName" value="<?php echo $_GET['quizname'] ?>"/>
        <input type="hidden" id="quizId" value="<?php echo $_GET['quizid'] ?>"/>
        <input type="hidden" id="category" value="<?php echo $_GET['category'] ?>"/>
    </div>
    <br/>
    <div data-bind="foreach: questions, visible: questions().length > 0">
        <br/>    
            <div data-bind="attr:{id:questionid} ">
            <input value="moveUp" type="button" data-bind=" click: $parent.moveUp, enable:  questionid() !='0'"/>
            <input value="moveDown" type="button" data-bind="click: $parent.moveDown, enable: $parent.questions().length > 1 && questionid() < $parent.questions().length-1"/>
            <label>Question</label>
            <input data-bind="value: question" />
            Is correct
            <input value="Delete" type="button" data-bind="click: $parent.removeQuestion"/>
            <div data-bind="foreach: answers, visible: answers().length > 0 ">
                <div data-bind="attr:{id:answerid} ">
                    <input value="moveUp" type="button" data-bind=" click: $parent.moveUp, enable: answerid() !='0'"/>
                    <input value="moveDown" type="button" data-bind="click: $parent.moveDown, enable: $parent.answers().length > 1 && answerid() < $parent.answers().length-1"/>
                    <label>Answer</label>
                    <input data-bind="value: answer" />
                    <input type="radio" data-bind="checked: iscorrect, attr:{name:$parent.questionid} "/>
                    <input value="Delete" type="button" data-bind="click: $parent.removeAnswer"/>
                </div>
                </div>
                <div>
                <input type="button" value="Add Answer" data-bind="click: addAnswer"/>
            </div>
        </div>
        <br/>
    </div>
    <input type="button" value="Add Question"  data-bind="click: addQuestion"/>
    <input type="submit" value="Save" data-bind="click:save "/>
</form>




    function Answer() {
        this.answer = ko.observable();
        this.iscorrect = ko.observable();
        this.answerid = ko.observable();
    }

编辑:

我修剪了java脚本,以显示我认为麻烦的区域; 我认为问题是淘汰赛没有看到单选按钮被取消选中

单击保存按钮时,生成的json输出显示已检查的所有复选框

请查看小提琴http://jsfiddle.net/Vpr4F/

0 个答案:

没有答案