--赋值无效的问题!在线急等!100分!结帖马上给分

yybjroam 2006-04-21 07:26:50
for each x in rs.Fields
x.value="ff"
next

请问:
rs是记录名, x.value="ff"这一句的赋值作用怎么无效 ?
我怎么才能在这里修改x.value的值?
...全文
223 23 打赏 收藏 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
hreoghost 2006-04-22
  • 打赏
  • 举报
回复
关注
soft_2008 2006-04-22
  • 打赏
  • 举报
回复
- -
iuhxq 2006-04-22
  • 打赏
  • 举报
回复
for each x in rs.Fields
rs.Fields(x).value="ff"
next
iamykf 2006-04-22
  • 打赏
  • 举报
回复
rs.fields改成rs.fields()
www_7di_net 2006-04-22
  • 打赏
  • 举报
回复
另外你最好加上form对象名字
for each x in rs.Fields
form.x.value="ff"
next
www_7di_net 2006-04-22
  • 打赏
  • 举报
回复
你把name换成id试试
yybjroam 2006-04-22
  • 打赏
  • 举报
回复
修改商品分类字段的内容!如果不修改!就像下面这样:
商品大类
22
23

修改后就如下面这样:

商品大类
上衣
裤子
itzhiren 2006-04-22
  • 打赏
  • 举报
回复
楼主想改导出标题?
yybjroam 2006-04-22
  • 打赏
  • 举报
回复
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../css.css" rel="stylesheet" type="text/css">
</head>

<body><br>
<table width="95%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="16" bgcolor="f1f1f1">
<div align="center"><font color="#000000">Execl表生成</font></div>
</td>
</tr>
<tr>

<td height="107" bgcolor="#FFFFFF">
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<form name="form1" method="post" action="ebiao2.asp?action=add">
<tr>
<td>开始日期:</td>
<td>
<select name="year1" class="wenbenkuang">
<%for i=2003 to 2100%>
<option value="<%=i%>" <%if year(now())=i then%>selected<%end if%>><%=i%></option>
<%next%>
</select>
年
<select name="month1" class="wenbenkuang">
<%for i=1 to 12%>
<option value="<%=i%>" <%if year(date())=i then %>selected<% end if %>><%=i%></option>
<%next%>
</select>
月
<select name="day1" class="wenbenkuang">
<%for i=1 to 31%>
<option value="<%=i%>" ><%=i%></option>
<%next%>
</select>
日 </td>
</tr>
<tr>
<td width="70">结束日期:</td>
<td width="278">
<select name="year2" class="wenbenkuang">
<%for i=2003 to 2100%>
<option value="<%=i%>" ><%=i%> </option>
<%next%>
</select>
年
<select name="month2" class="wenbenkuang">
<%for i=1 to 12%>
<option value=<%=i%> ><%=i%> </option>
<%next%>
</select>
月
<select name="day2" class="wenbenkuang">
<%for i=1 to 31%>
<option value=<%=i%> <%if year(date())=i then%>selected<%end if%>><%=i%> </option>
<%next%>
</select>
日 </td>
</tr>
<tr>
<td height="22">生成文件名:</td>
<td height="22"><input type="text" name="filename">
格式:yourfile.<FONT face=Verdana>xls</FONT></td>
</tr>
<tr>
<td height="22" colspan="2">选择导出数据参数:</td>
</tr>
<tr>
<td height="22" colspan="2"><input type="checkbox" name="bianhao" value=1>
编号  <select name="dalei" onChange=chsel() class="wenbenkuang">
<option value="xxx" selected>全部大类</option>
<%set gg=server.createobject("adodb.recordset")
sqlgg="select anclassid,anclass from shop_anclass order by anclassid"
gg.open sqlgg,conn,1,1
do while not gg.eof%>
<option value="<%=gg("anclassid")%>"><%=gg("anclass")%></option>
<%gg.movenext
loop%>
</select>
  <select name="xiaolei">
<option value="xxx" selected>全部小类</option>
</select>
 
<input type="checkbox" name="bookname" value=1>
商品名称
 
<input type="checkbox" name="lirui" value=1>利润
 
<input type="checkbox" name="chengjiaocount" value=1>销售量  <input type="checkbox" name="jinjia" value=1>
商品进价
 
<input type="checkbox" name="chushoujia" value=1>
商品出售价
 
<input type="checkbox" name="qipiname" value=1>
起批单位
 
<input type="checkbox" name="qipi" value=1>
起批量
 
<input type="checkbox" name="model" value=1>
商品颜色
 
<input type="checkbox" name="didian" value=1>
供货厂商
 
<input type="checkbox" name="addtime" value=1>
上架日期  <input type="checkbox" name="fhsj" value=1>
出售日期 </td>
</tr>
<tr>
<td height="22" colspan="2">生成文件路径说明:如果填入的文件名如:yourfile.xls 生成后就在当前文件夹下,如果带路径(d:\ff.xls)则为所填入的路径(d:\ff.xls)!</td>
</tr>
<tr>
<td height="22" colspan="2">
<div align="center">
<input type="submit" class="go-wenbenkuang" name="Submit" value="生 成" >
</div>
</td>
</tr>
</form>
</table>

</td>
</tr>
</table><br>
<!--#include file="copyright.asp"-->
</body>
</html>
yybjroam 2006-04-22
  • 打赏
  • 举报
回复
<!--#include file="conn.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>1 then
response.Write "<div align=center><font size=80 color=red><b>您没有此项目管理权限!</b></font></div>"
response.End
end if
end if
action=request.querystring("action")
filename=request.form("filename")
if action="add" then

if right(filename,4)<>".xls" then
response.write "<script language=JavaScript>" & chr(13) & "alert('输入的文件格式不正确!')</script>"
response.write"javascript:history.go(-1)</SCRIPT>"
end if


'获取导出参数
dim strLine,responsestr,strf,strlirui,strj,strdanjia
strLine=""
strf=""
strlirui=""
strj=""
strdanjia=""
dim bianhao,dalei,xiaolei,bookname,lirui,chengjiaocount,jinjia,chushoujia,qipiname,qipi,model,didian,addtime,fhsj,bookcontent
if request.form("bianhao")=1 then
strLine=strLine&"编号"&chr(9)
strf="ProdId,"
end if
strLine=strLine&"商品大类"&chr(9)
strf=strf&"anclassid,"
strLine=strLine&"商品小类"&chr(9)
strf=strf&"nclassid,"
if request.form("bookname")=1 then
strLine=strLine&"商品名称"&chr(9)
strf=strf&"bookname,"
end if
if request.form("lirui")=1 then
strLine=strLine&"利润"&chr(9)
strf=strf&"lirui,"
strlirui="lirui"
end if
if request.form("chengjiaocount")=1 then
strLine=strLine&"销售量"&chr(9)
strf=strf&"chengjiaocount,"
end if
if request.form("jinjia")=1 then
strLine=strLine&"进价"&chr(9)
strf=strf&"jinjia,"
end if
if request.form("chushoujia")=1 then
strLine=strLine&"出售价"&chr(9)
strf=strf&"danjia,"
strdanjia="danjia"
end if
if request.form("qipiname")=1 then
strLine=strLine&"起批单位"&chr(9)
strf=strf&"bookchuban,"
end if
if request.form("qipi")=1 then
strLine=strLine&"起批量"&chr(9)
strf=strf&"qipi,"
end if
if request.form("model")=1 then
strLine=strLine&"商品颜色"&chr(9)
strf=strf&"model,"
end if

if request.form("didian")=1 then
strLine=strLine&"供货商"&chr(9)
strf=strf&"didian,"
end if
if request.form("addtime")=1 then
strLine=strLine&"入库时间"&chr(9)
end if
strf=strf&"adddate,"
if request.form("fhsj")=1 then
strLine=strLine&"出售时间"&chr(9)
strf=strf&"fhsj"
strj="fhsj"
end if

if strLine="" or strLine="adddate," then
response.write "<script language=JavaScript>" & chr(13) & "alert('参数为能为空!')</script>"
response.write"javascript:history.go(-1)</SCRIPT>"
end if
if request.form("lirui")=1 then
if request.form("chushoujia")<>1 or request.form("jinjia")<>1 then
response.write "<script language=JavaScript>" & chr(13) & "alert('如果您选中了利润刚请选择进价和出售价')</script>"
response.write"javascript:history.go(-1)</SCRIPT>"
end if
end if
'获取导出参数结束
day1="#"&trim(Request.Form("month1"))&"-"&trim(Request.Form("day1"))&"-"&trim(Request.Form("year1"))&"#"
day2="#"&trim(Request.Form("month2"))&"-"&trim(Request.Form("day2"))&"-"&trim(Request.Form("year2"))&"#"
set rs=server.createobject("adodb.recordset")
if right(strf,1)="," then
strf=left(strf,len(strf)-1)
end if

xiaolei=request.form("xiaolei")
'筛选类别
if xiaolei<>"xxx" then
sqlsst= "select "&strf&" from shop_books where (datediff('d',adddate,"&day2&")>=0) and (datediff('d',"&day1&",adddate)>=0) and nclassid="&xiaolei&" order by adddate"
else
sqlsst= "select "&strf&" from shop_books where (datediff('d',adddate,"&day2&")>=0) and (datediff('d',"&day1&",adddate)>=0) order by adddate"
end if
rs.open sqlsst,conn,1,1

'导出到EXcel表开始
Set fs = server.CreateObject("scripting.filesystemobject")
'--假设你想让生成的EXCEL文件做如下的存放
filename = Server.MapPath(filename)
'--如果原来的EXCEL文件存在的话删除它
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--创建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
'--将表的列名先写入EXCEL
myfile.writeline strLine
dim strxv,strtime

Do while Not rs.EOF

strLine=""
if strdanjia<>"" or strj<>"" or strlirui<>"" then
set fft=server.createobject("adodb.recordset")
sqlfft="select actionid,bookid,dingdan,danjia,fhsj from shop_action where bookid="&rs("bookid")&""
fft.open sqlfft,conn,1,1
strdanjiav=fft("danjia")
strtime=fft("fhsj")
fft.close
set fft=nothing
end if

for each x in rs.Fields
str2=split(strf,",")
for i=0 to ubound(str2)
if str2(i)="danjia" then
rs.fields(x).value=strxv
end if
if str2(i)="lirui" then
rs.fields(x).value=rs("chengjiaocount")*(strdanjiav - rs("jinjia"))
end if
if str2(i)="danjia" then
rs.fields(x).value=strdanjiav
end if
if str2(i)="fhsj" then
rs.fields(x).value=strtime
end if
if str2(i)="anclassid" then
set fft=server.createobject("adodb.recordset")
sqlfft="select anclassid,anclass from shop_anclass where anclassid="&rs("anclassid")&""
fft.open sqlfft,conn,1,1
if not fft.eof then
rs.fields(x).value=111
end if
fft.close
set fft=nothing
end if
if str2(i)="nclassid" then
set fft=server.createobject("adodb.recordset")
sqlfft="select nclassid,nclass from shop_nclass where nclassid="&rs("nclassid")&""
fft.open sqlfft,conn,1,1
if not fft.eof then
rs.fields(x).value=222
end if
fft.close
set fft=nothing
end if
next

strLine= strLine &x.value & chr(9)
next
'--将表的数据写入EXCEL
myfile.writeline strLine
rs.MoveNext
loop

rs.Close
set rs = nothing

set myfile = nothing
Set fs=Nothing

response.write "<script language=JavaScript>" & chr(13) & "alert('导出数据成功!')</script>"
end if
%>
<script language=JavaScript>
<%dim i,j
set rs_s=server.createobject("adodb.recordset")
rs_s.open "select * from shop_anclass order by anclassid",conn,1,1
%>
var selects=[];
selects['xxx']=new Array(new Option('选择小类','xxx'));
<%
for i=1 to rs_s.recordcount
%>
selects['<%=rs_s("anclassid")%>']=new Array(
<%
set rs_s1=server.createobject("adodb.recordset")
rs_s1.open "select * from shop_nclass where anclassid="&rs_s("anclassid")&" order by nclass",conn,1,1
if rs_s1.recordcount>0 then
for j=1 to rs_s1.recordcount
if j=rs_s1.recordcount then
%>
new Option('<%=trim(rs_s1("nclass"))%>','<%=trim(rs_s1("nclass"))%>'));
<% else
%>
new Option('<%=trim(rs_s1("nclass"))%>','<%=trim(rs_s1("nclassid"))%>'),
<%
end if
rs_s1.movenext
next
else
%>
new Option('','0'));
<%
end if
rs_s1.close
set rs_s1=nothing
rs_s.movenext
next
rs_s.close
set rs_s=nothing
%>
function chsel(){
with (document.form1){
if(dalei.value) {
xiaolei.options.length=0;
for(var i=0;i<selects[dalei.value].length;i++){
xiaolei.add(selects[dalei.value][i]);
}
}
}
}
</script>
yybjroam 2006-04-22
  • 打赏
  • 举报
回复
我按各位说的做了可还是不行!
在此我感谢各位!但是问题还在!我特把代码帖出来
我要做的效果是: 用户选择所要导出到EXECEL表的参数后就导出所有所选参数的数据!
当导出参数是商品的大小类时,在导出到execel表时把商品分类id换成想对应的名称!
有三个表!一是商品表!二是商品大类分类表!三是商品小类分类表!
代码如下:
请帮我调试一下!
bingdian37 2006-04-21
  • 打赏
  • 举报
回复
不懂
bingdian37 2006-04-21
  • 打赏
  • 举报
回复
不懂
yybjroam 2006-04-21
  • 打赏
  • 举报
回复
我的目的是更新x.value的值!不是更新rs.fields(i).value的值!楼上各位说的都不行啊!
rowei 2006-04-21
  • 打赏
  • 举报
回复
没有rs.Update
youzi520 2006-04-21
  • 打赏
  • 举报
回复
for i=0 to rs.fields.count-1

rs.Fields(i).value="ff"
next
用这个吧
什么都不能 2006-04-21
  • 打赏
  • 举报
回复
楼主?你记录中的每个字段的值都是ff吗?
for each x in rs.Fields
x.value=x.name
next
rs.update
是是非非 2006-04-21
  • 打赏
  • 举报
回复
For Each的语法是这样的

For Each Key In Collection

Key可能是数字,也可能是字符串
是集合的索引
是是非非 2006-04-21
  • 打赏
  • 举报
回复
for each x in rs.Fields
rs.Fields(x).value="ff"
next
Whinee 2006-04-21
  • 打赏
  • 举报
回复
rs.Fields(x)="ff"
rs.update
加载更多回复(3)

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧