标题:急!请高手帮助解决,为什么在sub中得不表单上的控件值?
只看楼主
asp2008
Rank: 2
等 级:论坛游民
帖 子:15
专家分:10
注 册:2010-4-3
结帖率:50%
已结贴  问题点数:20 回复次数:4 
急!请高手帮助解决,为什么在sub中得不表单上的控件值?
因为在选择框中设定了submit,所以用sub定义保存过程,请高手帮助解决,为什么在sub中得不表单上的控件值?源代码如下:
<%@ LANGUAGE="VBScript" %>
<html>
<head>
</head>
<body>
<script LANGUAGE="VBSCRIPT" >
<!--
Sub myadd_OnClick
dim msg,mylrqx,mylrfw,mylrsm
mylrqx=request.form("menuqx")//获取用户选择框值,但录入库中却为空值???
mylrfw=request.form("menufw")//获取项目选择框值,但录入库中却为空值???
mylrsm=request.form("lrmenusm")//获取文本框值,但录入库中却为空值???
<%
mysysda="[01_mainmenu]"

Set sqlconn = Server.CreateObject("ADODB.Connection")
connstr="Driver={SQL Server};Server=......."//连接语句
sqlconn.open connstr
   mmymenuadd = trim(Request("myadd"))
   set rst=server.createobject("adodb.recordset")
   sqlrst="select max(leftid) as newleftid from [01_mainmenu]"
   rst.open sqlrst,sqlconn,1,1
   if rst.recordcount>0 then
      mybhcount=cstr(cint(trim(rst("newleftid")))+1)
      if len(trim(mybhcount))<=1 then
          mybhcount="0"&trim(mybhcount)
      else
          mybhcount=mybhcount
      end if
   end if
   rst.close
   set rst=nothing
   set rsmenu=server.createobject("adodb.recordset")
   sqlmenu="select * from "&trim(mysysda)&" where menuqx='"&trim(mylrqx)&"' and menufw='"&trim(mylrfw)&"'"
   rsmenu.open sqlmenu,sqlconn,1,3
   if rsmenu.recordcount>0 then
      set rs=server.createobject("adodb.recordset")   
      sql="select * from "&trim(mysysda)&" where menusm='"&trim(mylrsm)&"' and menuqx='"&trim(mylrqx)&"' and menufw='"&trim(mylrfw)&"'"
      rs.open sql,sqlconn,1,3
      if rs.recordcount>0 then

      else
         rs.addnew
         rs("leftid")=trim(mybhcount)
         rs("menusm")=trim(mylrsm)
         rs("menuclj")="gly\left_menu.asp"
         rs("menuqx")=trim(mylrqx)
         rs("menufw")=trim(mylrfw)
         rs.update
         rs.close
         set rs=nothing
      end if            
   else
      if len(trim(lrmenubh))<=1 then
         mylrmenubh="0"&trim(lrmenubh)
      else
         mylrmenubh=trim(mylrmenubh)
      end if
      rsmenu.addnew
      rsmenu("leftid")=trim(mylrmenubh)
      rsmenu("menusm")=trim(mylrsm)
      rsmenu("menuclj")="menu.asp"
      rsmenu("menuqx")=trim(mylrqx)
      rsmenu("menufw")=trim(mylrfw)
      rsmenu.update
   end if
   rsmenu.close
   set rsmenu=nothing
   %>
End Sub
-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<form name="fqs" action="sys_add_menutop.asp" method="post" target="result">
<center>
<div align="center"><b><font color="#FF0000">增加功能</font></b></font>
    </marquee>
</div>
<div align="center">
  <table width="439" height="157" border="1">
        
          <td width="99"><div align="center">用户</div></td>
         
        <td width="171"><select name="menuqx" style="width:152px;" onChange= "fqs.submit()">
            <option value="">--请选择--</option>
            <option value="操作用户">操作用户</option>
            <option value="查询用户">查询用户</option>      
        </select>          </td>
            <td><div align="left"><font color="#FF0000">* 请选择</font></div></td>
        </tr>
        <tr>
          <td width="99"><div align="center">项目</div></td>
          <td width="171"><select name="menufw" style="width:152px;" onChange= "fqs.submit()">
            <option value="">--请选择--</option>
            <option value="任务进度">任务进度</option>
            <option value="综合信息">综合信息</option>     
          </select></td>
          <td><div align="left"><font color="#FF0000">* 请选择</font></div></td>
        </tr>
          <tr>
          <td width="99"><div align="center">功能</div></td>
          <td><input type="text" name="lrmenusm"></td>
          <td><div align="left"><font color="#FF0000">* 请录入</font></div></td>
        </tr>
        <tr>
  </table>
  
</div>
</form>
</center>
<div align="center">
  <input type="button" name="myadd" value="保存">
</div>

</body>
</html>
搜索更多相关主题的帖子: sub 表单 控件 
2010-10-16 13:51
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
得分:20 
这种取值方法是服务器端的方法。客户端用 对象名.value之类的方法取得。

★★★★★为人民服务★★★★★
2010-10-16 14:05
asp2008
Rank: 2
等 级:论坛游民
帖 子:15
专家分:10
注 册:2010-4-3
得分:0 
回复 2楼 cnfarer
谢谢楼上的回答,但是我用=fqs.menusm.value试过同样取不到值,结果还是空怎么办?
2010-10-16 14:08
asp2008
Rank: 2
等 级:论坛游民
帖 子:15
专家分:10
注 册:2010-4-3
得分:0 
经过测试问题应该出现在下面,不加<% %>这段取值没有问题,但是不加<% %>以后的连接及录入操作出现错误,加了<% %>以后,在<% %>中却取不到fqs.menuqx.value的值,应该怎么才行?
<script LANGUAGE="VBSCRIPT" >
<!--
Sub myadd_OnClick
dim msg,mylrqx,mylrfw,mylrsm
mylrqx=fqs.menuqx.value//能获取值
mylrfw=fqs.menufw.value//能获取值
mylrsm=fqs.lrmenusm.value//能获取值
<%
.....
   %>
End Sub
-->
</script>
2010-10-16 15:37
a2003052107
Rank: 2
等 级:论坛游民
帖 子:5
专家分:16
注 册:2011-2-11
得分:0 
<%
Sub myadd_OnClick
dim msg,mylrqx,mylrfw,mylrsm
mylrqx=request.form("menuqx")//获取用户选择框值,但录入库中却为空值???
mylrfw=request.form("menufw")//获取项目选择框值,但录入库中却为空值???
mylrsm=request.form("lrmenusm")//获取文本框值,但录入库中却为空值???
mysysda="[01_mainmenu]"

Set sqlconn = Server.CreateObject("ADODB.Connection")
connstr="Driver={SQL Server};Server=......."//连接语句
sqlconn.open connstr
   mmymenuadd = trim(Request("myadd"))
   set rst=server.createobject("adodb.recordset")
   sqlrst="select max(leftid) as newleftid from [01_mainmenu]"
   rst.open sqlrst,sqlconn,1,1
   if rst.recordcount>0 then
      mybhcount=cstr(cint(trim(rst("newleftid")))+1)
      if len(trim(mybhcount))<=1 then
          mybhcount="0"&trim(mybhcount)
      else
          mybhcount=mybhcount
      end if
   end if
   rst.close
   set rst=nothing
   set rsmenu=server.createobject("adodb.recordset")
   sqlmenu="select * from "&trim(mysysda)&" where menuqx='"&trim(mylrqx)&"' and menufw='"&trim(mylrfw)&"'"
   rsmenu.open sqlmenu,sqlconn,1,3
   if rsmenu.recordcount>0 then
      set rs=server.createobject("adodb.recordset")   
      sql="select * from "&trim(mysysda)&" where menusm='"&trim(mylrsm)&"' and menuqx='"&trim(mylrqx)&"' and menufw='"&trim(mylrfw)&"'"
      rs.open sql,sqlconn,1,3
      if rs.recordcount>0 then

      else
         rs.addnew
         rs("leftid")=trim(mybhcount)
         rs("menusm")=trim(mylrsm)
         rs("menuclj")="gly\left_menu.asp"
         rs("menuqx")=trim(mylrqx)
         rs("menufw")=trim(mylrfw)
         rs.update
         rs.close
         set rs=nothing
      end if            
   else
      if len(trim(lrmenubh))<=1 then
         mylrmenubh="0"&trim(lrmenubh)
      else
         mylrmenubh=trim(mylrmenubh)
      end if
      rsmenu.addnew
      rsmenu("leftid")=trim(mylrmenubh)
      rsmenu("menusm")=trim(mylrsm)
      rsmenu("menuclj")="menu.asp"
      rsmenu("menuqx")=trim(mylrqx)
      rsmenu("menufw")=trim(mylrfw)
      rsmenu.update
   end if
   rsmenu.close
   set rsmenu=nothing
   End Sub%>

2011-02-14 10:19



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




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

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