当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: {bcb5+ado+access}下面代码中,4个字段都为text型,s2,s为ansistring,程序运行后,其它三个字段值都正常,唯独gjmc字段的值不正常---无论s2是什么值(都是汉字开头),数据库表中gjmc字段值都成为“bm"或"bm?",请问这是为什么?怎样解决? dm->yfgjb->append(); ... dm->yf......
 ·"区间" 怎么翻译    »显示摘要«
    摘要: 如题 ......


Request 对 象 问 题(分不够再加)

关于问卷调查系统问题      
  现在有很多类似的题目      
  但是选项数目是随机的      
     
  例如      
  ---------------------      
  您所在部门都与那些部门有业务或行政管理间的联系:      
  []生产部门                         []销售部门                         []市场部门                         []财务部门                              
  []信息中心                         []人事部门                         []采购部门                         []物流储运                              
  []法律部门                         []勘探部门                         []资料中心                         []工程技术部门      
  []技术支持部门                         []客户服务部门                         []纪审监察部门      
  ------------------------------      
  体现在HTML中      
  <input     type="checkbox"     name="checkbox1"     value="checkbox1">      
  <input     type="checkbox"     name="checkbox2"     value="checkbox2">      
  <input     type="checkbox"     name="checkbox3"     value="checkbox3">      
                                                ...                                                                 ...                                                         ...      
                                                ...                                                                 ...                                                         ...      
     
  strResult1=Request("checkbox1")      
  strResult2=Request("checkbox2")      
  strResult3=Request("checkbox3")      
            ...                                     ...      
            ...                                     ...      
     
  strResult=strResult1     &     strResult2     &     strResult3      
     
  题目和选项都已经存入数据库      
     
  现在要求读取数据库显示出题目和各个选项      
  然后用户填写相应的表单;      
  再把结果写入数据库      
     
  现在每个题目的选项数目不同      
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^      
     
  如何实现用request对象     动态的把每个题目的结果存入数组里      
  可否实现      
     
     
  就是可否实现这样的功能      
  -------      
  for     i     =1     to     n      
                result=result     &     request("checkbox(i)")      
                                                                                            ^^^^^^^^^^^^^^^^^^      
  next      
  --------      
  当然写的肯定不对了      
 

NO.1   作者: abigfrog

<%   for     i     =1     to     n   %>  
  <input   type="checkbox"   name="Q<%=i%>"   value="<%=rs("选项id")%>"><%=rs("选项")%>  
  <%   next   %>  
   
  接收页面  
  --------------  
  dim   aryid()  
  for   i=1   to   m   m是被选中的选项数目  
      aryid(i)=request.form("Q"&i)   这个就是被选中的选项的ID  
  next  
 

NO.2   作者: tigerwen01

用while   循环:  
  <%while   not   Rs.Eof   %>  
          <tr>    
              <td   width="5%"   height="17"   bgcolor="#DFEEF9">    
                  <input     name="V"     type=radio   value="<%=Rs("选项id")%>"   checked>  
                  <input   type="hidden"   name="<%=Rs("选项id")%>"   value="<%=Rs("调查标题")%>">    
              </td>    
              <td   width="95%"   height="17"   bgcolor="#DFEEF9"><%=Trim(Rs("选项内容"))%></td>    
          </tr>    
          <%Rs.MoveNext%>    
          <%Wend%>

NO.3   作者: possible_Y

<%   for     i     =1     to     n   %>  
  <input   type="checkbox"   name="mycheck"   value="<%=rs("选项id")%>"><%=rs("选项")%>  
  <%   next   %>  
   
  接收页面  
  --------------  
  dim   aryid()  
  for   i=1   to   Request.Form("mycheck").Count  
      aryid(i)=Request.Form("mycheck")(i)  
  next  
   
 

NO.4   作者: ministrybill

用这个更简单:  
  <%   for     i     =1     to     n   %>  
  <input   type="checkbox"   name="mycheck"   value="<%=rs("选项")%>"><%=rs("选项")%>  
  <%   next   %>  
   
  mycheck=request.form("mycheck")  
  response.write   mycheck  
  结果就是:   生产部门,市场部门,财务部门,采购部门,信息中心   这样的形式

NO.5   作者: superdullwolf

Form  
  The   Form   collection   retrieves   the   values   of   form   elements   posted   to   the   HTTP   request   body   by   a   form   using   the   POST   method.  
   
  Syntax  
  Request.Form(element)[(index)|.Count]    
     
  Parameters  
  element    
  Specifies   the   name   of   the   form   element   from   which   the   collection   is   to   retrieve   values.    
  index    
  An   optional   parameter   that   enables   you   to   access   one   of   multiple   values   for   a   parameter.   It   can   be   any   integer   in   the   range   1   to   Request.Form(parameter).Count.    
  Remarks  
  The   Form   collection   is   indexed   by   the   names   of   the   parameters   in   the   request   body.   The   value   of   Request.Form(element)   is   an   array   of   all   of   the   values   of   element   that   occur   in   the   request   body.   You   can   determine   the   number   of   values   of   a   parameter   by   calling   Request.Form(element).Count.   If   a   parameter   does   not   have   multiple   values   associated   with   it,   the   count   is   1.   If   the   parameter   is   not   found,   the   count   is   0.  
   
  To   reference   a   single   value   of   a   form   element   that   has   multiple   values,   you   must   specify   a   value   for   index.   The   index   parameter   may   be   any   number   between   1   and   Request.Form(element).Count.   If   you   reference   one   of   multiple   form   parameters   without   specifying   a   value   for   index,   the   data   is   returned   as   a   comma-delimited   string.  
   
  When   you   use   parameters   with   Request.Form,   the   Web   server   parses   the   HTTP   request   body   and   returns   the   specified   data.   If   your   application   requires   unparsed   data   from   the   form,   you   can   access   it   by   calling   Request.Form   without   any   parameters.  
   
  You   can   use   an   iterator   to   loop   through   all   the   data   values   in   a   form   request.   For   example,   if   a   user   filled   out   a   form   by   specifying   two   values,   Chocolate   and   Butterscotch,   for   the   FavoriteFlavor   parameter,   you   could   retrieve   those   values   by   using   the   following   script.  
   
  <%  
  For   Each   item   In   Request.Form("FavoriteFlavor")  
      Response.Write   item   &   "<BR>"  
  Next  
  %>  
     
  The   preceding   script   would   display   the   following.  
   
  Chocolate  
  Butterscotch  
     
  The   same   output   can   be   generated   with   a   For...Next   loop,   as   shown   in   the   following   script.    
   
  <%  
  For   i   =   1   To   Request.Form("FavoriteFlavor").Count  
      Response.Write   Request.Form("FavoriteFlavor")(i)   &   "<BR>"  
  Next  
  %>  
     
  You   can   use   this   iterator   to   display   the   parameter   name,   as   shown   in   the   following   script.  
   
  <%   For   Each   x   In   Request.Form   %>  
  Request.Form(   <%=   x   %>   )   =   <%=   Request.Form(x)   %>   <BR>  
  <%   Next   %>  
     
  This   script   displays   the   following   on   the   browser.    
   
  FavoriteFlavor   =   Chocolate  
  FavoriteFlavor   =   Butterscotch  
     
  Example  
  Consider   the   following   form.  
   
  <FORM   ACTION   =   "/scripts/submit.asp"   METHOD   =   "post">  
  <P>Your   first   name:   <INPUT   NAME   =   "firstname"   SIZE   =   48>  
  <P>What   is   your   favorite   ice   cream   flavor:   <SELECT   NAME   =   "flavor">  
  <OPTION>Vanilla    
  <OPTION>Strawberry    
  <OPTION>Chocolate    
  <OPTION>Rocky   Road</SELECT>  
  <p><INPUT   TYPE   =   SUBMIT>  
  </FORM>  
     
  From   that   form,   the   following   request   body   might   be   sent.  
   
  firstname=James&flavor=Rocky+Road  
     
  The   following   script   can   then   be   used.    
   
  Welcome,     <%=   Request.Form("firstname")   %>.    
  Your   favorite   flavor   is   <%=   Request.Form("flavor")   %>.  
     
  The   following   output   is   the   result.  
   
  Welcome,   James.   Your   favorite   flavor   is   Rocky   Road.  
     
  If   the   following   script   is   used  
   
  The   unparsed   form   data   is:     <%=   Request.Form   %>    
     
  the   output   would   be  
   
  The   unparsed   form   data   is:     firstname=James&flavor=Rocky+Road  
     
  Applies   To  
  Request   Object    
   
  See   Also  
  ClientCertificate,   Cookies,   QueryString,   ServerVariables    
   
     
 

NO.6   作者: superdullwolf

 
  Contents     Index     ic   Contents  
     
  Previous   ic:   children  
  Next   ic:   embeds  
     
   
  elements  
   
  --------------------------------------------------------------------------------  
   
  Description  
   
  Retrieves   a   collection,   in   source   order,   of   all   elements   in   a   given   form.   This   collection   can   contain   any   combination   of   INPUT,   SELECT,   and   TEXTAREA   elements.    
   
  Syntax  
  object.elements(index)  
   
   
   
  Parameter   Description    
  object     A   FORM   element.      
  (index)     Optional.   An   integer   or   a   string   specifying   the   index   value   of   the   element   to   retrieve.   Integer   indexes   are   zero-based,   meaning   the   first   element   in   the   collection   has   index   0.   A   string   index   is   valid   only   if   the   string   is   a   name   or   identifier   of   at   least   one   element   in   the   document.    
   
  Remarks  
   
  This   collection   is   indexed   first   by   name,   then   by   identifier.   If   duplicate   names   are   found,   a   collection   of   those   named   items   is   returned.   Collections   of   duplicate   names   must   subsequently   be   referenced   by   ordinal   position.    
   
  Property  
   
  length    
   
  Methods  
   
  item,   tags    
   
  Applies   To  
   
  FORM    
   
   
   
  --------------------------------------------------------------------------------  
   
      of   Page    
  &copy;   1997   Microsoft   Corporation.   All   rights   reserved.   Terms   of   Use.    
 

NO.7   作者: superdullwolf

<form   action="#"       method=post>  
  <INPUT     type=checkbox   name=checkbox1   value=A>  
  <INPUT     type=checkbox   name=checkbox1   value=B>  
  <INPUT     type=checkbox   name=checkbox1   value=C>  
  <INPUT     type=submit   value=Button   name=button1>  
  </form>  
  第一种办法:  
  <%  
  For   Each   item   In   Request.Form("checkbox1")  
  if   len(cstr(item))=0   then  
  Response.Write   "没选择"  
  else  
  Response.Write   item  
  end   if  
  Next  
  %><hr>第二种办法:  
   
  <%  
  For   i   =   1   To   Request.Form("checkbox1").Count  
      Response.Write   Request.Form("checkbox1")(i)    
  Next  
  %>  
  以上代码经测试好使


 ·怎样随机生成一个4位整数    »显示摘要«
    摘要: 我做的网页登陆部分想要做个个附加密码,有那位高手可以指点一下 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE