| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 475 人关注过本帖
标题:一个关于复选框的
只看楼主 加入收藏
fslifei
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-9-18
收藏
 问题点数:0 回复次数:3 
一个关于复选框的
程序样本:
<%
dim okid,okid1,okid2
   set rs=conn.execute("Select * from Product where ProductID="&request.querystring("id") )   
   ClassID=rs("ClassID")
   ProductName=rs("ProductName")
   SmallPic=rs("SmallPic")
   Content=rs("Content")
   phflag=rs("phflag")
   ggflag=rs("ggflag")
   xyflag=rs("xyflag")
   jyflag=rs("jyflag")
   RsClose()
%>
<%
   if request.querystring("action")="modify" then
      if request2.form("ProductName")="" then
         response.write "<script>alert('信息标题不能为空!');window.location.href='AddNews.asp';</script>"
         response.end
      end if

      
      url="action="&action&"&keyword="&Request.QueryString("keyword")&"&class="&Request.QueryString("class")&"&page="&Request.QueryString("page")
      set rs=server.createobject("adodb.recordset")
      sql="select * from Product where ProductID="&request.querystring("id")
      rs.open sql,conn,3,3
      
   okid=trim(request2.form("seleClassID"))
   if okid<>empty then
      if instr(okid,"*")>0 then
         okid1=left(okid,instr(okid,"*")-1)
         okid2=right(okid,len(okid)-instr(okid,"*"))
      else
         okid1=okid
         okid2=okid  
      end if
   else
         okid1=okid
         okid2=okid   
   end if   

      rs("ClassID")=okid1
      rs("anClassID")=okid2
      rs("ProductName")=request2.form("ProductName")
      rs("ChangeDate")=date()
      
      if request2.form("phflag")<>empty then  rs("phflag")=request2.form("phflag")
      if request2.form("ggflag")<>empty then  rs("ggflag")=request2.form("ggflag")
      if request2.form("xyflag")<>empty then  rs("xyflag")=request2.form("xyflag")
      if request2.form("jyflag")<>empty then  rs("jyflag")=request2.form("jyflag")
   
      if Request2.form("SmallPic")<>"" then
         DelFile(SmallPic)
         rs("SmallPic")=request2.form("SmallPic")
      end if
      rs("Content")=request2.form("Content")
      if session("AdminName")=empty then
         rs("user")="管理员"
      else
         rs("user")=session("AdminName")
      end if
      rs.update
      RsClose()
      
      response.write "<script>alert('提交成功!');window.location.href='ManageNews.asp?"&url&"';</script>"
   end if
%>
……
……
……
 <td height="22" align="right" class="forumRowHighlight" style="width: 11%">
    文章带图像:</td>
    <td width="4%" class="forumRow">
    <input type="checkbox" name="phflag" value="1" <%if phflag=1 then%>checked><%end if%></td>
    <td width="12%" class="forumRow" style="background-color: #EAEAF3">
    <p align="right">加入公告栏目:</td>
    <td width="4%" class="forumRow">
    <input type="checkbox" name="ggflag" value="1" <%if ggflag=1 then%>checked><%end if%></td>
    <td width="12%" class="forumRow" style="background-color: #EAEAF3">
    <p align="right">加入校园动态:</td>
    <td width="3%" class="forumRow">
    <input type="checkbox" name="xyflag" value="1" <%if xyflag=1 then%>checked><%end if%></td>
    <td width="18%" class="forumRow">
    <p align="right">加入底部滚动图像区:</td>
    <td width="24%" class="forumRow">
    <input type="checkbox" name="jyflag" value="1" <%if jyflag=1 then%>checked><%end if%></td>
    <td width="88%" class="forumRow" colspan="8">
        <INPUT type="hidden" name="Content" value="<%=server.HTMLEncode(Content)%>">
图片附件: 游客没有浏览图片的权限,请 登录注册

在IE8环境下工作时,如图的四个复选框,如果以前没有选定的话,点选以后可以正常赋值,一旦选定以后想要去除选定的话总是失败,中间省略号的部分是表格定义,应该与程序无关。另外,重置按纽按下无效。
小弟新手,实在找不出原因,麻烦各位大侠出手,请版主不要删我贴子。
另,刚注册的号,实在是没分,不好意思了。

[ 本帖最后由 fslifei 于 2010-9-18 21:45 编辑 ]
搜索更多相关主题的帖子: 复选 
2010-09-18 21:32
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
收藏
得分:0 
复选框未选择时的值未定义,所以未选中时就会出错!
在插入时定义,
if request2.form("phflag")=1 then
rs("phflag")=request2.form("phflag")
else
rs("phflag")=0
end if
...
request2.form("phflag"),这里为什么是request2呢?不明白

QQ:63572063
2010-09-18 22:44
fslifei
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-9-18
收藏
得分:0 
以下是引用wangjy500在2010-9-18 22:44:09的发言:

复选框未选择时的值未定义,所以未选中时就会出错!
在插入时定义,
if request2.form("phflag")=1 then
rs("phflag")=request2.form("phflag")
else
rs("phflag")=0
end if
...
request2.form("phflag"),这里为什么是request2呢?不明白
改成这样以后一提交直接是白屏。我感觉应该是在IE8环境下表格传值传不了,具体是什么原因一直查不出来。request2是在uploadclass.asp中定义过的。

[ 本帖最后由 fslifei 于 2010-9-19 10:58 编辑 ]
2010-09-19 10:18
fslifei
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-9-18
收藏
得分:0 
解决了,原因是上下没有呼应,改成以下代码后问题解决,感谢二楼提示。

      if request2.form("phflag")="1" then
          rs("phflag")=1
          else
          rs("phflag")=0
      end if
      if request2.form("ggflag")="1" then
         rs("ggflag")=1
         else
         rs("ggflag")=0
      end if
      if request2.form("xyflag")="1" then
         rs("xyflag")=1
         else
         rs("xyflag")=0
      end if
      if request2.form("jyflag")="1" then
         rs("jyflag")=1
         else
         rs("jyflag")=0
      end if

……
……
……
    <%if phflag=1 then%>
       <input type="checkbox" name="phflag" value="1" checked>
       <%else%>
       <input type="checkbox" name="phflag" value="1">      
    <%end if%></td>
    <td width="12%" class="forumRow" style="background-color: #EAEAF3">
    <p align="right">加入公告栏目:</td>
    <td width="4%" class="forumRow">
    <%if ggflag=1 then%>
       <input type="checkbox" name="ggflag" value="1" checked>
       <%else%>
       <input type="checkbox" name="ggflag" value="1">      
    <%end if%></td>
    <td width="12%" class="forumRow" style="background-color: #EAEAF3">
    <p align="right">加入校园动态:</td>
    <td width="3%" class="forumRow">
    <%if xyflag=1 then%>
       <input type="checkbox" name="xyflag" value="1" checked>
       <%else%>
       <input type="checkbox" name="xyflag" value="1">      
    <%end if%></td>
2010-09-20 08:36
快速回复:一个关于复选框的
数据加载中...
 
   



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

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