delphi-7 – Traverse inputs with the same name and get all values


I have a web application in which I input hidden a dynamic number of values through a form to a Delphi action .

In action , I wanted to know a way to get all values with the same name.

When it's a single value , I use request.ContentFields.Values['numero']

I'm passing the form inputs as follows:

<input type="hidden" name="numero[]" value="123" />
<input type="hidden" name="numero[]" value="456" />
<input type="hidden" name="numero[]" value="789" />

But how do I get everyone into action ?

  • The conventional way returns only the content of the first input .
  • I tried to create a dynamic array and pass it to it, but it didn't work.


Come on, I don't know what you're doing through Delphi, so I'm going to take an approach that we have in C#.

If you have something like this:

<input type="hidden" name="numero[0]" value="123" />
<input type="hidden" name="numero[1]" value="456" />
<input type="hidden" name="numero[2]" value="789" />

Then you would have something like this in delphi:

  TIntegerArray: Array of Integer;

procedure TMinhaClass.MinhaAction(numero: TIntegerArray);
  I: integer;
  // podendo então:
  for I := 0 to High(numero) do
     // fazer o que deseja com "numero[I]".

This answer is entirely based on speculation. Another point is that the fields must always have an order, without breaks, as something like:


Something like this you would only receive values ​​with index 0 and 1 in your action , the field with index 3 would not receive due to the break. Confirm this too.

Scroll to Top