如果我单击一个复选框,也会选中另一个复选框

时间:2017-10-05 11:30:20

标签: php html

如果我点击一个复选框,则同时选中另一个复选框。

Error

addquiz.php

<?php 
$unique_id = time().'_'.uniqid(true); 
$userid = $this->session->userdata('cp_userid');
?> 
<!-- DC QUIZZ -->
<form class="addquizform" id="quiz_form_<?php echo $unique_id;?>" data-form = "<?php echo $unique_id;?>" data-user = '<?php echo $userid ?>'>
<input type="hidden" name="sid" value="<?php echo $sectionId;?>">
<input type="hidden" name="cid" value="<?php echo $courseId;?>">
<div class="dc-quizz-info dc-course-item">
    <div class="dc-content-title">
        <h5 class="xsm black">Quiz : Title of quiz</h5>
        <div class="course-region-tool">
            <input type="button" value = "Save" class="mc-btn-3 btn-style-1 savequiz save" id="save_quiz_<?php echo $unique_id;?>">
        </div>
    </div>      
    <div class="quizz-body dc-item-body">
        <div class="form-item form-checkbox checkbox-style">
            <input type="checkbox" id="showanswer" value="1" name="showanswer">
            <label for="showanswer">
                <i class="icon-checkbox icon md-check-1"></i>
                Show Answer
            </label>
        </div>          
        <div class="form-item form-checkbox checkbox-style">
            <input type="checkbox" id="limittime">
            <label for="limittime">
                <i class="icon-checkbox icon md-check-1"></i>
                Limit time
            </label>
        </div>

        <div class="time">
            <div class="form-item">
                <input type="text" name="limittime">
                <label for="">mins</label>
            </div>
        </div>
        <div class="form-item">
            <input type="text" placeholder="Quiz Title" class="fullwidth" name="quiztitle">
        </div>
        <div class="form-item">
            <input type="text" placeholder="Short introduction" class="fullwidth" name="quizintro">
        </div>
    </div>
</div>
</form>
<!-- END / DC QUIZZ -->

当我再添加一个测验时,它会要求选中复选框,但是当我点击上面的复选框时,复选框也会被选中。如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

请检查名称和ID您已定义缺少复选框的ID和名称

<div class="dc-quizz-info dc-course-item">
        <div class="dc-content-title">
            <h5 class="xsm black">Quiz : Title of quiz</h5>
            <div class="course-region-tool">
                <input type="button" value = "Save" class="mc-btn-3 btn-style-1 savequiz save" id="save_quiz_<?php echo $unique_id;?>">
            </div>
        </div>      
        <div class="quizz-body dc-item-body">
            <div class="form-item form-checkbox checkbox-style">
                <input type="checkbox" id="showanswer" value="1" name="showanswer">
                <label for="showanswer">
                    <i class="icon-checkbox icon md-check-1"></i>
                    Show Answer
                </label>
            </div>          
            <div class="form-item form-checkbox checkbox-style">
                <input type="checkbox" name="limitcheck" id="limitcheck">
            </div>

            <div class="time">
                <label for="limittime">
                    <i class="icon-checkbox icon md-check-1"></i>
                    Limit time
                </label>
                <div class="form-item">
                    <input type="text" value="" id="limittime" name="limittime">
                    <label for="">mins</label>
                </div>
            </div>
            <div class="form-item">
                <input type="text" placeholder="Quiz Title" class="fullwidth" name="quiztitle">
            </div>
            <div class="form-item">
                <input type="text" placeholder="Short introduction" class="fullwidth" name="quizintro">
            </div>
        </div>
    </div>