作者 anyv
1 个管道 的构建 通过 耗费 0 秒

投票列表

... ... @@ -13,6 +13,24 @@ class VoteController extends AdminBaseController{
}
//添加投票
public function voteadd(){
$title = input('post.title');
$options = input('post.xuan');
$option = explode(',', $options);
$arr['title'] = $title;
$arr['pid'] = 0;
$id = Db::name('vote') -> insertGetId($arr);
foreach ($option as $key => $value) {
$data['pid'] = $id;
$data['options'] = $value;
Db::name('vote') -> insert($data);
}
return true;
}
}
... ...
... ... @@ -36,7 +36,7 @@
<div class="modal-body txuanx">
<div class="input-group">
<span class="input-group-addon">标题:</span>
<input type="text" class="form-control" placeholder="">
<input type="text" name="title" class="form-control" placeholder="">
</div>
<div class="input-group" style="margin-top: 5px;">
<span class="input-group-addon">选项:</span>
... ... @@ -69,7 +69,11 @@
arr[j] = item.value;
});
str = arr.join(',');
console.log(str);
title = $("input[name='title']").val();
$.post("{:url('Vote/voteadd')}", {title:title,xuan:str}, function(data) {
});
}
</script>
... ...