<?php include_once 'init-lite.php'; 
?>
<script type="text/javascript">
  function updateCfg(var1){
 	var kevalue =encodeURIComponent($("#kevalue"+var1).val());
 	$.ajax({
		type: "POST", //提交的类型
		url: "admin-config-save.php",//提交地址
		data: "_dc="+new Date().getTime() +"&ID=" + var1 +"&kevalue=" + kevalue,//参数
		success: function(data){ //回调方法
			$("#myDiv").html(data);
		}
	});
  }
 </script>
 <form class="ui-filterable">
      <input id="myFilter" placeholder="根据名称搜索" size="6" data-type="search" data-clear-btn="true">
    </form>
  <table data-role="table" id="myTable"  data-mode="columntoggle" class="ui-responsive table-stroke" data-filter="true" data-input="#myFilter" data-autodividers="true" >

    <thead>
        <tr>
          <th width="54%">项目</th>
          <th width="46%" id="myDiv">设置</th>
        </tr>
      </thead>
      <tbody><?php
$sql = "SELECT ID,Descr,keyname,kevalue FROM configWeb where keyname<> 'km800'";
$values = $orders->query($sql);
if (is_iterable($values)){
  foreach ($values as $pCategories){ 
//对查询后的结果进行转码 2018-07
$pCategories['Descr'] = loadFromMssql($pCategories['Descr']);
$pCategories['keyname'] = loadFromMssql($pCategories['keyname']);
$pCategories['kevalue'] = loadFromMssql($pCategories['kevalue']);
 ?>
<tr>
<td><?php echo $pCategories['Descr'];$id=$pCategories['ID'] ?><input name="ID" id="ID" type="hidden" value="<?php echo $id; ?>" />
</td>
<td>
<?php if ($pCategories['kevalue']=="0" || $pCategories['kevalue']=="1") { ?>
 <select name="slider2" id="kevalue<?php echo $id; ?>" data-role="slider" onchange="updateCfg(<?php echo $id; ?>);">
    <option value="0" 
		<?php if ($pCategories['kevalue']=="0") echo 'selected="selected"';?>
     >Off</option>
    <option value="1" 
		<?php if ($pCategories['kevalue']=="1") echo 'selected="selected"';?>
     >On</option>
</select>
<?php } else { ?>
 <label for="textfield"></label>
  <input name="textfield" type="text" id="kevalue<?php echo $id; ?>"  onblur="	updateCfg(<?php echo $id; ?>);" value="<?php echo $pCategories['kevalue']; ?>" /></td>
  <?php   }    ?>
</tr>
<?php   } }   ?>
<tr>
  <td>&nbsp;</td>
  <td><input type="button" name="button" id="button" value="保存" /></td>
</tr> 
</tbody>
    </table>