如何在asp响应中添加数字

时间:2014-05-15 15:52:57

标签: javascript jquery asp-classic

我是asp的新手。这是我的代码:

response.write("<script>")
do until rs.EOF
  for each x in rs.Fields
    response.write(" var ")
    response.write("CC=" & x.value)
  next
  rs.MoveNext
loop
response.write("</script>")

如何使输出为var CC1= x.value,然后让下一个循环返回var CC2=x.value,依此类推???

1 个答案:

答案 0 :(得分:1)

增加计数器变量。 你还需要一个“;”

response.write("<script>")

dim counter: counter = 0

do until rs.EOF
  for each x in rs.Fields
    counter = counter + 1
    response.write "var CC" & counter & "=" & x.value & ";"
  next
  rs.MoveNext
loop

数组形式:var CC[]; ... CC[counter] =可以替代。