Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 您必须选择至少一个选项作为正确选项 修正的 请提供,以便易于理解问题所在。我已添加并修改了我的代码,以便您可以在SwatiHi查看,下面的答案是否解决了您的问题?你可以投票并接受:)对不起,如果我之前没有回答你,我最近几个月一直很忙,但是你的回答有一_Javascript_Php_Html_Jquery - Fatal编程技术网

Javascript 您必须选择至少一个选项作为正确选项 修正的 请提供,以便易于理解问题所在。我已添加并修改了我的代码,以便您可以在SwatiHi查看,下面的答案是否解决了您的问题?你可以投票并接受:)对不起,如果我之前没有回答你,我最近几个月一直很忙,但是你的回答有一

Javascript 您必须选择至少一个选项作为正确选项 修正的 请提供,以便易于理解问题所在。我已添加并修改了我的代码,以便您可以在SwatiHi查看,下面的答案是否解决了您的问题?你可以投票并接受:)对不起,如果我之前没有回答你,我最近几个月一直很忙,但是你的回答有一,javascript,php,html,jquery,Javascript,Php,Html,Jquery,您必须选择至少一个选项作为正确选项 修正的 请提供,以便易于理解问题所在。我已添加并修改了我的代码,以便您可以在SwatiHi查看,下面的答案是否解决了您的问题?你可以投票并接受:)对不起,如果我之前没有回答你,我最近几个月一直很忙,但是你的回答有一个灵活的点,能够找到我一直在寻找的解决方案。非常感谢。 <form id="dynamic-form" action="" method="post"> <div c

您必须选择至少一个选项作为正确选项

修正的




请提供,以便易于理解问题所在。我已添加并修改了我的代码,以便您可以在SwatiHi查看,下面的答案是否解决了您的问题?你可以投票并接受:)对不起,如果我之前没有回答你,我最近几个月一直很忙,但是你的回答有一个灵活的点,能够找到我一直在寻找的解决方案。非常感谢。
<form id="dynamic-form" action="" method="post">
<div class="content">
    <div class="box box-success box-solid">
        <div class="box-header with-border">
            <h3 class="box-title">Evaluation</h3>
        </div>
        <div class="panel-body">
            <div class="dynamicform_wrapper"> //where select and change applies
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>Questions</th>
                            <th style="width: 500px;">Options</th>
                            <th class="text-center" style="width: 90px;">
                                <button type="button" class="add-item btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span></button>
                            </th>
                            
                        </tr>
                    </thead>
                    <tbody class="container-items">
                        <tr id="0" class="item">//ID that I use to find the elements

                            <td class="question"> //where do i apply colspan
                                <table class="table table-bordered table-striped">
                                    <tbody>
                                        <tr>
                                            <td class="vcenter">
                                                <span class="panel-title-address">Nr: 1</span>
                                            </td>
                                            <td class="vcenter">
                                                <input type="hidden" id="qquestion-0-id_question" name="qquestion[0][id_question]" value="28">                                        
                                                <div class="form-group field-qquestion-0-type_id required">
                                                    <label class="control-label" for="qquestion-0-type_id">Question Type</label>
                                                    <select id="qquestion-0-type_id" class="form-control" name="qquestion[0][type_id]" onchange="">
                                                        <option value="">-- Select --</option>
                                                        <option value="1" selected="">SINGLE / MULIPLE ANSWER</option> // OPTION 1
                                                        <option value="2">OPEN QUESTION</option> // OPTION 2
                                                    </select>
                                                    <p class="help-block help-block-error"></p>
                                                </div> 
                                                <div class="form-group field-qquestion-0-title required">
                                                    <input type="text" id="qquestion-0-title" class="form-control" name="qquestion[0][title]" value="" maxlength="250" placeholder="Títle">
                                                    <p class="help-block help-block-error"></p>
                                                </div>                      
                                                <div class="form-group field-qquestion-0-score required">
                                                    <input type="text" id="qquestion-0-score" class="form-control" name="qquestion[0][score]" value="" placeholder="Score" data-plugin-inputmask="inputmask_2fdcbd27">
                                                    <p class="help-block help-block-error"></p>
                                                </div>                                        
                                                <div class="form-group field-qquestion-0-image">
                                                    <label class="control-label" for="qquestion-0-image">Image</label>
                                                    <input type="file" id="qquestion-0-image" class="empty-value" name="qquestion[0][image]">
                                                    <p class="help-block help-block-error"></p>
                                                </div>                                        
                                                <div class="form-group field-qquestion-0-justify_answer">
                                                    <div class="checkbox">
                                                        <label style="padding:5px;" for="qquestion-0-justify_answer">
                                                        <input type="hidden" name="qquestion[0][justify_answer]" value="0"><input type="checkbox" id="qquestion-0-justify_answer" name="qquestion[0][justify_answer]" value="">
                                                        Do you want the answer to be justified?
                                                        </label>
                                                        <p class="help-block help-block-error"></p>

                                                    </div>
                                                </div> 
                                            </td>
                                            <td class="clearfix"></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                            <td class="item-opcion">                                
                                <div class="dynamicform_inner">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <th>Description</th>
                                                <th class="text-center">
                                                    <button type="button" class="add-opcion btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span></button>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody class="container-opciones">
                                            <tr class="opcion-item">
                                                <td class="vcenter">
                                                    <input type="hidden" id="qoption-0-0-id_option" name="qoption[0][0][id_option]" value="">                
                                                    <div class="input-group">
                                                        <span class="input-group-addon">
                                                            <div class="form-group field-qoption-0-0-opcion_correcta required">
                                                                <div class="checkbox">
                                                                    <label style="padding:5px;" for="qoption-0-0-opcion_correcta">
                                                                        <input type="hidden" name="qoption[0][0][opcion_correcta]" value="0"><input type="checkbox" id="qoption-0-0-opcion_correcta" name="qoption[0][0][opcion_correcta]" value="1">
                                                                    </label>
                                                                    <p class="help-block help-block-error"></p>
                                                                </div>
                                                            </div>                    
                                                        </span>
                                                        <div class="form-group field-qoption-0-0-title_option required">
                                                            <input type="text" id="qoption-0-0-title_option" class="form-control" name="qoption[0][0][title_option]" value="2" maxlength="250" placeholder="Opción">
                                                            <p class="help-block help-block-error"></p>
                                                        </div>                
                                                    </div>
                                                </td>
                                                <td class="text-center vcenter" style="width: 90px;">
                                                    <button type="button" class="remove-opcion btn btn-danger btn-xs"><span class="glyphicon glyphicon-minus"></span></button>
                                                </td>
                                            </tr>       
                                        </tbody>
                                    </table>
                                </div>
                                <div class="form-group text-error-check required has-error" style="display: none;">
                                    <p class="help-block help-block-error">You must select at least 1 option as correct.</p>
                                </div>
                            </td>
                            <td class="text-center vcenter" style="width: 90px; verti">
                                <button type="button" class="remove-item btn btn-danger btn-xs"><span class="glyphicon glyphicon-minus"></span></button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>        
        </div>
    </div>
</div>
<div class="form-group">
    <button type="submit" class="btn btn-primary"><span class="fa fa-edit"></span> Modificar</button>
</div>
$(".dynamicform_wrapper").on("change","select",function(){     
        if ($(this).val()== 2) {
            $('#0').find('.option-item').not(':first').remove(); //removed all entries found in
            $('#0').find('.option-item:first').hide(); 
            $('#0').find('.item-option').hide(); 
            $('#0').find('.question').attr('colspan',2);
        }else if ($(this).val()== 1){
            //var numberNotChecked = $('#0').find('.option-item input:checkbox:not(":checked")').length;
            var numberChecked = $('#0').find('.option-item input:checkbox:checked').length;
            $('#0').find('.container-options').append(newtr); //add input
            $('#0').find('.item-option').show(); 
            $('#0').find('.question').removeAttr('colspan',2);
            $( "#dynamic-form" ).submit(function( event ) {
                if(numberChecked > 0){
                    $('#0').find('.text-error-check').hide();
                    $('#0').find('.dynamicform_inner').removeAttr("style");
                } else {
                    $('#0').find('.text-error-check').show();
                    $('#0').find('.dynamicform_inner').css({'border':'2px solid #dd4b39','background-color':'white'});
                    event.preventDefault();
                }
            });
       }});