<?php 
$Line1=0;
include_once 'init-lite.php'; 
?>
<script type="text/javascript">
  function updateCfg(var1){
	//var SQL_CategoryID =encodeURIComponent($("#CategoryID"+var1).val());
	var CategoryName =encodeURIComponent($("#CategoryName"+var1).val());
	var CategoryID =encodeURIComponent($("#CategoryID"+var1).val());
 
 	$.ajax({
		type: "POST", //提交的类型
		url: "admin-Categories-save.php",//提交地址
		data: "_dc="+new Date().getTime()+"&CategoryName=" + CategoryName+"&CategoryID=" + CategoryID,//参数
		success: function(data){ //回调方法
			$("#myDiv").html(data);
		}
	});
  }
 </script>

<form class="ui-filterable">
      <input id="myFilter" placeholder="根据名称搜索"  data-type="search" data-clear-btn="true">
    </form>
    <span id="myDiv"></span>
  <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>ID</th>
          <th>类别</th>
          <th>保存</th>
        </tr>
      </thead>
      <tbody>
<?php
$sql = "SELECT CategoryID,CategoryName FROM Categories";  
$values = $orders->query($sql);
if (is_iterable($values)){
  foreach ($values as $pProductsAddMenu){ 
 $Line1++; 
$pProductsAddMenu['CategoryName']=loadFromMssql($pProductsAddMenu['CategoryName']);
?>                         
<tr>
<td><input name="CategoryID<?php echo $Line1; ?>" type="text" id="CategoryID<?php echo $Line1; ?>" value="<?php echo $pProductsAddMenu['CategoryID']; ?>" size="3"/></td>
<td><span style='color:red;display: none;'><?php echo $pProductsAddMenu['CategoryName']?></span><input name="CategoryName<?php echo $Line1; ?>" type="text" id="CategoryName<?php echo $Line1; ?>" value="<?php echo $pProductsAddMenu['CategoryName']; ?>" size="25"/></td>
<td><button type="button" onclick="updateCfg(<?php echo $Line1; ?>);">save</button></td>
</tr> <?php }} ?>
      </tbody>
    </table>