| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <div class="form-group"></div>
- <div class="form-group">
- <label class="col-xs-12 col-sm-3 col-md-1 control-label">添加问题</label>
- <div class="col-xs-12 col-sm-3 col-md-2">
- <select class="form-control tpl-category-parent" id="choice" name="">
- <option value="1">单选</option>
- <option value="2">多选</option>
- </select>
- </div>
- <div class="col-xs-12 col-sm-3 col-md-2 input-group-btn">
- <a class="btn btn-primary btn-add-type" href="javascript:;" onclick="appendText();"><i id="add_field" class="fa fa-plus" title=""></i> 增加一个字段</a>
- </div>
- </div>
- <div class="form-group"></div>
- <table class="table">
- <thead>
- <tr>
- <th style="width:52px;text-align: right">类型</th>
- <th style="width:50px;text-align: center">排序</th>
- <th style="width:200px;text-align: center">名称</th>
- <th style="width:50px;text-align: center">必填 </th>
- <th style="width:550px;">设置</th>
- </tr>
- </thead>
- <tbody id="type-items">
- </tbody>
- </table>
- <script language='javascript'>
- var num =0;
- var answer = 0;
- function appendText() {
- var type = $("#choice").val();
- if(type == 1){
- var name = '单选';
- }else{
- var name = '多选';
- }
- var option = '<tr style="border-top: hidden" id="problem_'+num+'">' +
- '<td style="width:52px; text-align: right;">' +
- '<input type="hidden" class="form-control" name="data[option]['+num+'][type]" value="'+type+'" placeholder="">' +
- '<sapn >'+name+'</span></td>' +
- '<td style="width:50px; text-align: center;">' +
- '<input type="text" class="form-control" name="data[option]['+num+'][sort]" value="" style="text-align: center;" placeholder=""></td>' +
- '<td style="width:100%;text-align: center;">' +
- '<input type="text" class="form-control" name="data[option]['+num+'][choice_title]" value="" ></td>' +
- '<td style="width:20px;text-align: center;">' +
- '<input type="checkbox" name="data[option]['+num+'][required]" value="1" ></td>' +
- '<td style="width:52px;"> ' +
- '<div class="col-sm-12 col-md-12" id="answer_'+num+'"></div>'+
- '<div class="col-sm-12 col-md-12"><a class="btn btn-primary btn-add-type" href="javascript:;" onclick="appendOption('+num+');">' +
- '<i id="add_field" class="fa fa-plus" title=""></i> 添加选项</a></div></div></td>' +
- '<td><a class="btn btn-default nav-del" href="javascript:;" onclick="problemClosed('+num+');">' +
- ' <i id="add_field" class="fa fa-times" title=""></i> </a></td>'+
- '</tr>';
- $("#type-items").append(option);
- num++
- }
- function appendOption(num) {
- console.log(num)
- var answer_option = '<ul id="an_'+answer+'">' +
- '<li class="col-sm-12 col-md-5">' +
- '<input type="text" class="form-control" name="data[option]['+num+'][choice][answer]['+answer+']" value="" style="text-align: center;" placeholder=""></li>' +
- '<li class="col-sm-12 col-md-5"> <div class="input-group">'+
- ' <input type="text" name="data[option]['+num+'][choice][fraction]['+answer+']" class="form-control discounts_value" value=""/>'+
- ' <div class="input-group-addon waytxt">分</div></div></li>'+
- '<a class="btn btn-default nav-del" style="border:none!important;" href="javascript:;" onclick="Closed('+answer+');">'+
- ' <i id="add_field" class="fa fa-times" title=""></i> </a>'+
- '</ul>';
- $("#"+"answer_"+num).append(answer_option);
- answer++
- }
- function problemClosed(num) {
- $("#"+"problem_"+num).empty();
- }
- function Closed(answer) {
- $("#"+"an_"+answer).empty();
- }
- </script>
|