[Solved] ASP – Changing variable name (numbering) or adding numbers to a variable in asc order to assign values


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 />")

The approach was sound you just needed to concatenate (&) the value of i on to the name of the Request.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.

solved ASP – Changing variable name (numbering) or adding numbers to a variable in asc order to assign values