Any idea what should I do or what am I doing wrong???
TIA,
Cezar
.Values only returns the first occurence. you´ll have to loop through the
.Names[Index] property to get all values. shouldn´t be too much of a
problem, you are handling a TString object, read the delphi doc´s on that,
it should look like this in your case:
foo=valuefoo
field_name=value1
field_name=value2
field_name=value3
humptydumpty=valueegg
.
.
.
christoph
I can't play with the .Names[Index] because before
displaying the listbox I have dynamically generated fields and
I'm don't know what's the index for the listbox.
Cezar
>..Values only returns the first occurence. you惻l have to loop through the
>..Names[Index] property to get all values. shouldn愒 be too much of a
>problem, you are handling a TString object, read the delphi doc愀 on that,
>it should look like this in your case:
>
>foo=valuefoo
>field_name=value1
>field_name=value2
>field_name=value3
>humptydumpty=valueegg
>..
>..
>..
>
>christoph
>
>
>
Here is some code I've used in the past....
procedure TWebModule1.ExtractMultipleSelectionValues(RequestField: string;
var MultipleValues: TStrings);
var
i: Integer;
tempList: TStrings;
begin
{ Since the ContentFields contains duplicate name/value pairs (only names
are duplicate)
I've had to use a tempList to add matching RequestField name/value to
and then
immideately put the value into MultipleValues list
}
tempList := TStringList.Create;
try
MultipleValues.Clear;
for i := 0 to Request.ContentFields.Count -1 do
if Request.ContentFields.Names[i] = RequestField then
begin
tempList.Clear;
tempList.Add(Request.ContentFields[i]);
MultipleValues.Add(tempList.Values[tempList.Names[0]]);
end;
finally
FreeAndNil(tempList);
end;
end;
Not sure why I used the logic I did, but it worked <g>
--
Shiv Kumar
The Delphi Apostle
http://www.matlus.com
http://www.delphisoap.com
function GetMultipleSelect(fieldname :string):TStrings;
var
values :TStrings;
count :integer;
value :string;
webfieldname :string;
fieldcount :integer;
begin
values := TStringList.Create;
values.Clear;
count := 0;
if Request.MethodType = mtPOST then
fieldcount := Request.ContentFields.Count
else
fieldcount := Request.QueryFields.Count;
while count < fieldcount do
begin
if Request.MethodType = mtPOST then
webfieldname := lowercase(Request.ContentFields.Names[count])
else
webfieldname := lowercase(Request.QueryFields.Names[count]);
if webfieldname = lowercase(fieldname) then
begin
if Request.MethodType = mtPOST then
value := Request.ContentFields[count]
else
value := Request.QueryFields[count];
delete(value, 1, pos('=', value));
values.Add(value);
end;
count := count + 1;
end;
Result := values;
end;