ASP - 在ASC以赋值给一个变量更改变量名(编号)或添加号码 [英] ASP - Changing variable name (numbering) or adding numbers to a variable in asc order to assign values

查看:752
本文介绍了ASP - 在ASC以赋值给一个变量更改变量名(编号)或添加号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何改变变量名按升序值分配给它们编号。例如:car_1,car_2,car_3,car_4 ........等等..我的编码是一样的东西;

How to change the variable name numbering in ascending order to assign values to them. eg: car_1, car_2, car_3, car_4........ so on.. my coding is something like;

for i=1 to 20
var(i) = request.form("car_"i)
next

foreach ......so on........

response.write(var(12) & "<br/>")

我需要一种方式来增加car_的数目,以每一辆车的价值分配给无功阵列。我尝试添加我是这样的:

I need a way to increase the number of 'car_' to assign each car value to the 'var' array. I have tried to add i like this:

var(i) = request.form("car_"&i)

var(i) = request.form("car_"i"")

和没有这些工作。我非常AP preciate您的帮助来解决这个问题。

and none of these work. I would very much appreciate your help to solve this.

推荐答案

这个例子是不是很清楚理想还可以更好,但更我看着它我越觉得你是使用VBScript,所以我打算尝试跨preT你正在尝试做的。

The example isn't very clear ideally it could be better but the more I look at it the more I think you are using VBScript, so I'm going to try an interpret what you are trying to do.

Dim i
Dim min_i: min_i = 1
Dim max_i: max_i = 20
Dim vars(max_i)

For i = min_i To max_i
  vars(i) = Request.Form("car_" & i)
Next
'Returns the value of Request.Form("car_12")
Call Response.Write(vars(12) & "<br />")

的方法是,你只需要来连接声音(&安培; )的值 I 上的名称的 Request.Forms 值。

这是值得指出的是,这是什么 @大卫中的their回答除了这个例子试图通过输出值的阵列,而不是直接向响应缓冲区。

It's worth pointing out that this is no different to what @David suggests in their answer except that this example tries to stay as close to the original requirement as possible by outputting the values to an Array instead of directly to the response buffer.

这篇关于ASP - 在ASC以赋值给一个变量更改变量名(编号)或添加号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆