<script type="text/javascript" src="{{ asset('vendor/jsvalidation/js/jsvalidation.js')}}"></script>
{!! JsValidator::formRequest('QxCMS\Modules\Client\Requests\Questionnaire\QuestionRequest', 'form#question-form'); !!}
<script type="text/javascript">
$(function(){
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
$('body').on('click', 'button#add-answer-btn', function(e){
var counter = $('form#question-form input[name^="name"]').length + 1;
var limit = 10;
if (counter > limit) {
alert("You have reached the maximum limit of choices.");
return false
}
var new_input = "<div class=\"form-group\">";
new_input += "<label class=\"control-label col-sm-2\">Choice "+ counter +". <i class=\"required\">*</i></label>";
new_input += "<div class=\"col-sm-10\">";
new_input += "<div class=\"input-group\">"
new_input += "<input type=\"text\" name=\"name[new_"+counter+"]\" class=\"form-control\" placeholder=\"New Choice\">";
new_input += "<div class=\"input-group-btn\">";
new_input += "<button class=\"btn btn-flat btn-danger\" type=\"button\" id=\"remove-answer-btn\"><i class=\"fa fa-times\"></i></button>";
new_input += "</div>";
new_input += "</div>";
/* new_input += "<div class=\"input-controls\">";
new_input += "<i class=\"remove-submit fa fa-times\"></i>";
new_input += "<i class=\"sort-submit fa fa-arrows-v\"></i>";
new_input += "</div>";*/
new_input += "</div>";
new_input += "</div>";
$('.choices').append(new_input);
return false;
});
$('body').on('click', 'button#remove-answer-btn', function(e){
$(this).closest('.form-group').remove();
});
$('select[name="question_type"]').on('change', function(){
var selected = $(this).val();
if(selected=='2')
{
$('.multiple-choice').css({'display':'block'});
$('.multiple-choice-add-btn').css({'display':'table-cell'});
$('.multiple-choice-add-btn').closest('.input-group').css({'display':'table'});
} else {
$('.multiple-choice').css({'display':'none'});
$('.multiple-choice-add-btn').closest('.input-group').css({'display':'block'});
$('.multiple-choice-add-btn').css({'display':'none'});
}
});
});
</script>