| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 721 人关注过本帖
标题:变量问题
只看楼主 加入收藏
jxzhu
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2008-6-11
结帖率:100%
收藏
 问题点数:0 回复次数:3 
变量问题
<% for i=1 to 4 %>
<tr>
<td align="center"><%=i%></td>
<% for j=1 to 7 %>
<td  align="center">
<%Dim  w=?
%>
<input name="<%w%>"  type="text"  size=7></td>
<% Next %>
</tr>
<% Next %>


我想把变量i和j转换成字串如w12,w37 ,w23等,然后把这个字串赋给变量w,再在input中name等于w的字串,怎么实现?
搜索更多相关主题的帖子: 变量 字串 name input 
2008-06-20 17:30
jxzhu
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2008-6-11
收藏
得分:0 
ASP中变量好难弄懂,比如在定义了name为变量并赋值后,之后在引用时却要加 &name& ,
2008-06-20 17:41
jxzhu
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2008-6-11
收藏
得分:0 
<%@LANGUAGE="VBScript" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
 <%
if session("admin_id")="" then
      response.write "<script language=JavaScript>{window.alert('对不起,您尚未登录或登录超时或登录超时!'); window.location.href='#';              }</script>"
  response.end
  end if
  %>  
  
<% set rs=server.createobject("adodb.recordset")
        sql="select * from jg    "
        rs.open sql,conn,1,1   %>
  
   <% name=rs("name")  %>
  <title>添加<%=name%>的课表</title>
 
 <table   border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FAE7F1" >
<form method="post" action="kb_add_sav.asp" name="form1"  >
<tr><td>
<table width=100%><tr>
<td align="center" >节次</td>
<% for j=1 to 7 %>
<td align="center">
<% dim rmb
     rmbs(j) %>
星期 <%=rmb %>
</td>
<% next %>
</tr>

<% for i=1 to 4 %>
<tr>
<td align="center"><%=i%></td>
<% for j=1 to 7 %>
<td  align="center">
<%    ws="w"&CStr(j)&CStr(i)
%>
<input name="<% =ws %>"  type="text"  size=7></td>
<% Next %>
</tr>
<% Next %>

<tr><td colspan="8" align="center">午 间 休 息</td></tr>
<% for i=5 to 7 %>
<tr>
<td align="center"><%=i%></td>
<% for j=1 to 7
    wa="w"&CStr(j)&CStr(i)   
%>
<td>
<input name="<% =wa %>"  type="text"   size=7></td>
</td>
<% next%>
</tr>
<% next %>



 
</td></tr>
<tr><td align="center" colspan=8>


      <p ><br><br><input type="submit" name="Submit" value="添加课表"style="width:80;background-color: #FFFF66; color: #000000; border: 1 solid #00CC00">
</p>



</td></tr></form>

</table>
<%
Function rmbs(num)
num = FormatNumber(num, 2)
Dim numList
Dim rmbList
Dim numLen
Dim numChar
Dim numstr
Dim n
Dim n1, n2
Dim hz
numList = "0一二三四五六日八九十"
rmbList = "分角元拾佰仟万拾佰仟亿拾佰仟万"

If num > 9999999999999.99 Then
    rmb = "超出范围的人民币值"
    Exit Function
End If
numstr = CStr(num * 100)
numLen = Len(numstr)
n = 1
Do While n <= numLen
    numChar = CInt(Mid(numstr, n, 1))
    n1 = Mid(numList, numChar + 1, 1)
    n2 = Mid(rmbList, numLen - n + 1, 1)
    If Not n1 = "jj零" Then
        hz = hz + CStr(n1) + CStr(n2)
    Else
        If n2 = "亿" Or n2 = "万" Or n2 = "元" Or n1 = "零" Then
          Do While Right(hz, 1) = "零"
            hz = Left(hz, Len(hz) - 1)
            Loop
        End If
        If (n2 = "亿" Or (n2 = "万" And Right(hz, 1) <> "亿") Or n2 = "元") Then
            hz = hz + CStr(n2)
        Else
            If Left(Right(hz, 2), 1) = "零" Or Right(hz, 1) <> "亿" Then
             hz = hz + n1
            End If
        End If
    End If
    n = n + 1
Loop
Do While Right(hz, 1) = "零"
    hz = Left(hz, Len(hz) - 1)
Loop
If Right(hz, 1) = "元" Then
    hz = hz + "整"
End If
rmb = left(hz,1)
End Function%>


  <%@LANGUAGE="VBScript" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->

<%
if session("admin_id")="" then
      response.write "<script language=JavaScript>{window.alert('对不起,您尚未登录或登录超时或登录超时!'); window.location.href='#';              }</script>"
  response.end
  end if
  %>  
  

 
<% name=trim(request("name"))
if name="" Or name=Null then  
response.write "<script language=javascript>{window.alert('姓名不能为空!请点击“确定”返回');window.history.go(-1);}</script>"
end if %>

 <%
set rs=server.CreateObject("adodb.recordset")
sql="select * from kb"
rs.open sql,conn,1,2
rs.addnew   
rs("name")=name
       for i=1 to 7
              for j=1 to 7
                                    
                                   wt=request.form("w"&CStr(j)&CStr(i))
                                   rs("w"&CStr(j)&CStr(i))=wt
              next                                                                                                  
          next  
    rs.update  
    rs.close
 %>

<script language=javascript>{window.alert('课表添加成功!请点击“确定”返回');window.history.go(-1);}</script>


基本上差不多了,没办法,新手理解力不够
2008-06-20 23:06
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
<% for i=1 to 4 %>
<tr>
<td align="center"><%=i%></td>
<% for j=1 to 7 %>
<td  align="center">
<%
   Dim  w
   w="w"&CStr(i)&CStr(j)
%>
<input name="<%=w%>"  type="text"  size=7></td>
<% Next %>
</tr>
<% Next %>
2008-06-20 23:32
快速回复:变量问题
数据加载中...
 
   



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

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