标题:复选框写入后可以读取但是修改不了
只看楼主
黑色羽翼
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-12-18
 问题点数:0 回复次数:0 
复选框写入后可以读取但是修改不了
在网页加上一个新产品和一个热卖产品复选框,添加产品那可以正常使用,修改的时候没有反应,请问是如何读取出数据呢,要怎么样修改,请高手们修改下。谢谢
代码如下:
添加页面:
<% dim title,pic,content,sclass
if request("action")="save" then
title=trim(request("title"))
entitle=trim(request("entitle"))
price=trim(request("price"))
num=trim(request("num"))
imgfile=trim(request("imgfile"))
Fclass=trim(request("szSheng"))
Fnclass=trim(request("szShi"))
pic=request("pic")
content=request("content")
encontent=request("encontent")
xinghao=request("xinghao")
news=request("news")
host=request("host")

if title="" or title="" or xinghao="" or price="" or pic="" or content="" or encontent="" then
response.Write "<script>alert('所有内容必须全部填写,请返回!');history.go(-1);</script>"
response.End()
end if

sql="select * from pud order by id desc"
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("entitle")=entitle
rs("price")=price
rs("num")=num
rs("imgfile")=imgfile
rs("xinghao")=xinghao
rs("bigclass")=Fclass
rs("smallclass")=Fnclass
rs("pic")=pic
rs("content")=content
rs("encontent")=encontent
if Request.Form("news")=1 then
  rs("news")=Request.Form("news")
else
  rs("news")=0
end if
  if Request.Form("host")=1 then
rs("host")=Request.Form("host")
else
  rs("host")=0
end if

rs.update
response.Write "添加成功!!"
    response.Write "<a href='anli_manage.asp'>"
    Response.Write "返回"
    Response.Write("</a>")
    response.Write "<meta http-equiv=""Refresh"" content=""3;url=anli_manage.asp"">"
    response.End
%>
<% rs.close
set rs=nothing
conn.close
set conn=nothing
 %>
    <%end if%>

-----------表单里面选择代码:
<label>
<input type="checkbox" name="news" id="news" value="1" <%if news then response.write ("checked")%>>新产品
<input type="checkbox" name="host" id="host"  value="1" <%if host then response.write ("checked")%>>热销产品</label>

修改页面代码:
<% dim title,pic,content,sclass,id
id=request("id")
if request("action")="save" then
id=trim(request("id"))
title=trim(request("title"))
entitle=trim(request("entitle"))
price=trim(request("price"))
num=trim(request("num"))
imgfile=trim(request("imgfile"))
Fclass=trim(request("szSheng"))
Fnclass=trim(request("szShi"))
pic=request("pic")
content=request("content")
encontent=request("encontent")
xinghao=request("xinghao")
news=request("news")
host=request("host")

if title="" or entitle="" or xinghao="" or price="" or pic="" or content="" or encontent="" then
response.Write "<script>alert('所有内容必须全部填写,请返回!');history.go(-1);</script>"
response.End()
end if
sql="select * from pud where id="&id
rs2.open sql,conn,1,3
rs2("title")=title
rs2("entitle")=entitle
rs2("price")=price
rs2("imgfile")=imgfile
rs2("xinghao")=xinghao
rs2("bigclass")=Fclass
rs2("smallclass")=Fnclass
rs2("pic")=pic
rs2("content")=content
rs2("encontent")=encontent
if Request.Form("news")=1 then
  rs("news")=Request.Form("news")
else
  rs("news")=0
end if
  if Request.Form("host")=1 then
rs("host")=Request.Form("host")
else
  rs("host")=0
end if

rs2.update
response.Write "修改成功!!"
    response.Write "<a href='anli_manage.asp'>"
    Response.Write "返回"
    Response.Write("</a>")
    response.Write "<meta http-equiv=""Refresh"" content=""3;url=anli_manage.asp"">"
    response.End
%>
<% rs2.close
set rs2=nothing
conn.close
set conn=nothing
 %>
    <%end if%>

------------------------表单里面显示修改代码:
<label>
<input type="checkbox" name="news" id="news" value="1" <%if news then response.write ("checked")%>>新产品
<input type="checkbox" name="host" id="host"  value="1" <%if host then response.write ("checked")%>>热销产品</label>
--------------------就是这里读不出,也修改不了

修改为:
<label>
<input type="checkbox" name="news" id="news" value="1" <%if rs("news") then response.write ("checked")%>>新产品
<input name="host" type="checkbox" id="host" value="1" <% if rs("host") then response.Write("checked")%>>热销产品</label>
可以读取出来数值,修改还是没有反应

[ 本帖最后由 黑色羽翼 于 2013-12-19 10:03 编辑 ]
搜索更多相关主题的帖子: request content action price title 
2013-12-18 17:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-425366-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018209 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved