<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>编辑</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  
  <script src="/public/js/jquery-1.11.3.min.js"></script>
  <script src="/public/js/jquery.form-3.36.0.min.js"></script>

  <link rel="stylesheet" href="/plugins/layui/css/layui.css">
  <link rel="stylesheet" href="/public/css/global.css">
  
</head>
<body>

<div class="layui-fluid" style="padding-right: 20px; margin-top: 50px;">
<div class="layui-form">
<form id="detail_form" method="post" target="_parent">
  <div class="layui-form-item">
    <label class="layui-form-label">题目类型</label>
    <div class="layui-input-block">
    <?php foreach($stemtypes as $onetype){ ?>
      <input type="radio" name="typechild" value="<?php echo $onetype->id; ?>" parentid="<?php echo $onetype->parentid; ?>" title="<?php echo $onetype->name; ?>" <?php if($stem->typechild==$onetype->id){echo 'checked';} ?>>
    <?php } ?>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="button" class="layui-btn" id="finished_button">下一步</button>
    </div>
  </div>
  <input type="hidden" name="courseid" value="<?php echo $stem->courseid; ?>">
  <input type="hidden" name="treeid" value="<?php echo $stem->treeid; ?>">
  <input type="hidden" name="stemid" value="<?php echo $stem->id; ?>">
  <input type="hidden" name="listview" value="">
</form>
</div>
</div>

<script type="text/javascript">
$(document).ready(function(){
  var listview = parent.$("#stem_form").find("input[name='listview']").val();
  $("#detail_form").find("input[name='listview']").val(listview);
  <?php if(empty($stem->id)){ ?>
  var courseid = parent.$("#stem_form").find("input[name='courseid']").val();
  var treeid = parent.$("#stem_form").find("input[name='treeid']").val();
  var stemid = parent.$("#stem_form").find("input[name='stemid']").val();
  $("#detail_form").find("input[name='courseid']").val(courseid);
  $("#detail_form").find("input[name='treeid']").val(treeid);
  $("#detail_form").find("input[name='stemid']").val(stemid);
  <?php }else{ ?>
  $("#detail_form").attr("action", "/glquesti/basic<?php echo $stem->typeid; ?>/index");
  $("#detail_form").submit();
  <?php } ?>
});
</script>

<script type="text/javascript">
$("#finished_button").click(function(){
  var typechked = $("#detail_form").find("input[name='typechild']:checked");
  var courseid = $("#detail_form").find("input[name='courseid']").val();
  var treeid = $("#detail_form").find("input[name='treeid']").val();
  var stemid = $("#detail_form").find("input[name='stemid']").val();
  var listview = $("#detail_form").find("input[name='listview']").val();
  if(typechked.length==0){
    layer.msg("请选择题目类型", {icon:2}); return false;
  }
  if(courseid==""){
    layer.msg("课程错误, 请刷新后重试", {icon:2}); return false;
  }
  if(treeid==""){
    layer.msg("知识点错误, 请刷新后重试", {icon:2}); return false;
  }
  var typeid = $(typechked).attr("parentid");
  $("#detail_form").attr("action", "/glquesti/basic"+ typeid +"/index");
  $("#detail_form").submit();
});
</script>

<script src="/plugins/layui/layui.all.js"></script>
</body>
</html>