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/>")
I need a way to increase the number of 'car_' to assign each car value to the 'var' array. I have tried to add it like this:
var(i) = request.form("car_"&i)
AND
var(i) = request.form("car_"i"")
and none of these work. I would very much appreciate your help to solve this.
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.
The approach was sound you just needed to concatenate (
&
) the value ofi
on to the name of theRequest.Forms
value.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.You can concatenate values in VBScript with the
&
operator. Such as:To demonstrate, go ahead and run this code in something like this online code editor (IE only, I suspect):
Which produces the following output:
The same also works in server-side VBScript:
Which produces the same output.