目的:从用户列表中选择相应的记录,在下面的表中显示做修改前的参照,并将修改提交相应的记录.
问题:修改数据另写了一个函数update(),但是修改数据不成功.请高手解答!
代码:
<!--#include file="../Connections/cli.asp" --><%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_cli_STRING;
Recordset1.Source = "SELECT * FROM dbo.users";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
<%
var Repeat1__numRows = 8;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
<!--
function secBoard(y1,y2,y3,y4,y5)

  tds1.innerText=y1;
  w1.value=y1;
  tds2.innerText=y2;
  w2.value=y2;
  tds3.innerText=y3;
  w3.value=y3;
  tds4.innerText=y4;
  w4.value=y4;
  tds5.innerText=y5;
  w5.value=y5;
  mainTable.tBodies[0].style.display="none";
  mainTable.tBodies[1].style.display="block";  
};
function update( )

d2=w2.value.replace(/ /g,"");
d3=w3.value.replace(/ /g,"");
d4=w4.value.replace(/ /g,"");
d5=w5.value.replace(/ /g,"");
MM_editQuery="update users set password='"+d2+"',username='"+d3+"',rightarea='"+d4+"',rightlevel='"+d5+"' where usercode='"+w1.value+"'";
  var MM_editCmd = Server.CreateObject('ADODB.Command');
    MM_editCmd.ActiveConnection = MM_cli_STRING;
    MM_editCmd.CommandText = MM_editQuery;
    MM_editCmd.Execute();
    MM_editCmd.ActiveConnection.Close();
alert("修改成功");
}
//-->
</script>
<style>
td  {
 font-size: 13px;
 line-height: 25px;
 border-collapse:collapse;

};
.td1  {
 font-size: 13px;
 line-height: 25px;
 border-collapse:collapse;
 border:1px solid #cccccc;
};
.td3  {
 font-size: 13px;
 line-height: 20px;
 border-collapse:collapse;
 border:1px solid #cccccc;
};
.td2  {
 font-size: 13px;
 line-height: 25px;
 border-collapse:collapse;
 border:1px solid #cccccc;
 cursor: hand;
}
</style>
</head><body>
<table width="666">
<tr><td align="center">用户权限管理</td></tr>
<tr><td>用户列表:</td></tr>
<tr><td height="240" valign="top">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse;" >
  <tr>
    <td width="50" class="td1">序号</td>
    <td width="100" class="td1">用户代码</td>
<td width="100" class="td1">用户密码</td>
    <td width="100" class="td1">用户名称</td>
    <td width="100" class="td1">权限范围</td>
    <td width="100" class="td1">操作权限</td>
    <td width="100" class="td1">说明</td>
  </tr>
  <% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
  <tr onMouseover="this.bgColor='orange'" onMouseOut="this.bgColor='white'">
      <td class="td1"></td>
      <td class="td1"><%code=(Recordset1.Fields.Item("usercode").Value)%><%=code%></td>
  <td class="td1"><%passwd=(Recordset1.Fields.Item("password").Value)%><%=passwd%></td>
      <td class="td1"><%name=(Recordset1.Fields.Item("username").Value)%><%=name%></td>
      <td class="td1"><%area=(Recordset1.Fields.Item("rightarea").Value)%><%=area%></td>
      <td class="td1"><%level=(Recordset1.Fields.Item("rightlevel").Value)%><%=level%></td>
      <td class="td2" onDblClick="secBoard('<%=code%>','<%=passwd%>','<%=name%>','<%=area%>','<%=level%>')">双击修改</td>
  </tr>
  <%
  Repeat1__index++;
  Recordset1.MoveNext();
}
%>
</table>
</td></tr>
<tr><td height="25"></td></tr>
</table>
<table name=mainTable id=mainTable  cellpadding="0" cellspacing="0">
<tbody style="display:block;">         
     <tr>       
        <td valign="top" >增加新用户</td>
          </tr>
        </tbody>
<tbody style="display:none;">         
     <tr>       
        <td valign="top" >
<table>
          <tr> 
            <td width="90" valign="top" class="td3" id=tds1></td>
            <td width="90" class="td3" id=tds2></td>
            <td width="90" class="td3" id=tds3></td>
            <td width="90" class="td3" id=tds4></td>
            <td width="90" class="td3" id=tds5></td>
          </tr>
  <tr><td colspan="5" height=15>修改为:</td></tr>
   <tr>
 <td >
        <input type="text" id="w1" value="" maxlength="10" size="15" height="25" readonly="1">      </td>
      <td>
        <input type="text" id="w2" value="" maxlength="10" size="15" height="25" >
      </td>
      <td>
        <input type="text" id="w3" value="" maxlength="10" size="15" height="25">
      </td>
      <td>
        <input type="text" id="w4" value="" maxlength="10" size="15" height="25">
      </td>
      <td>
        <input type="text" id="w5" value="" maxlength="10" size="15" height="25">
      </td>
    </tr>
     <tr><td colspan="5" height=15 align="center"><input type="button" value="提交修改" id="w6" size="15" onClick="update( )"></td></tr>
</table>      

</td>
          </tr>
        </tbody>
</table>
</body>
</html>
<%
Recordset1.Close();
%>