Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread How to submit all ListBox selected items
Fri, Jul 5 2013 12:33 PMPermanent Link

Sergei Safar

Hi,

suppose you have a TListBox on a TPanel and you execute the Panel.SubmitForm. Only the selected item is submitted. My question is: how to submit all selected items if the TListbox is a MultiSelect one?

Best regards,
Sergei Safar
Fri, Jul 5 2013 12:57 PMPermanent Link

Dan

Fiscalsoft

On 7/5/2013 12:33 PM, Sergei Safar wrote:
> Hi,
>
> suppose you have a TListBox on a TPanel and you execute the Panel.SubmitForm. Only the selected item is submitted. My question is: how to submit all selected items if the TListbox is a MultiSelect one?
>
> Best regards,
> Sergei Safar
>
Hi Sergei,
There is probably a much easier answer than this, but just an idea in
case it helps:

Say you submit via a TButton, then create an onbuttonclick event that
initiates an iteration with a conditional.  So for example, say your
ListBox is a list of forms than could be created (something I'm
currently working on):

i : integer;

begin
for i := 0 to {index of last item} do
if Selected[i] then TForm.create(nil);
end;

My code may be a little off but I think it illustrates the concept.
Hopefully this helps!

Dan
Fri, Jul 5 2013 4:09 PMPermanent Link

Ronald

You could put a TMemo onyour panel. Set the property Visible to false and
set the property DataSet en DataColumn to the proper field in your Table.
Before you actually submit the panel, you copy the content of the listbox to
the memo field.

Hope that helps.

"Sergei Safar" schreef in bericht
news:71699C09-9240-4FE3-9DBA-6CA342B18A77@news.elevatesoft.com...

Hi,

suppose you have a TListBox on a TPanel and you execute the
Panel.SubmitForm. Only the selected item is submitted. My question is: how
to submit all selected items if the TListbox is a MultiSelect one?

Best regards,
Sergei Safar
Mon, Jul 8 2013 2:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Sergei,

<< suppose you have a TListBox on a TPanel and you execute the
Panel.SubmitForm. Only the selected item is submitted. >>

What back-end are you using ?  You should see multiple values come through
with the same key value (the listbox control name).  You can test this in
the IDE using the loopback form submittal address:

http://localhost/formsubmit

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jul 8 2013 3:50 PMPermanent Link

Sergei Safar

Tim,

<<What back-end are you using ?>>

PHP and here is a piece of code written in PHP that works fine when EWB submits just one item:

$City = $_REQUEST("LBCity");

where LBCity is a TListBox at EWB side.

<<You should see multiple values come through with the same key value (the listbox control name).>>  
I can't see, maybe I am missing something here.

Best regards,
Sergei Safar
Wed, Jul 10 2013 11:25 AMPermanent Link

Sergei Safar

Hi Tim,

for some reason, PHP is not receiving all selected items, only the last one. Attached print screen of output of a "var_dump($_REQUEST);" command. As you can see only the last selected item is avaiable at back-end side.

Best regards,
Sergei Safar



Attachments: PSubmit.JPG
Thu, Jul 11 2013 12:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Sergei,

<< for some reason, PHP is not receiving all selected items, only the last
one. Attached print screen of output of a "var_dump($_REQUEST);" command. As
you can see only the last selected item is avaiable at back-end side. >>

See here:

http://stackoverflow.com/questions/2407284/how-to-get-multiple-selected-values-of-select-box-in-php

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 11 2013 5:06 PMPermanent Link

Sergei Safar

Hi Tim,

<<See here:
http://stackoverflow.com/questions/2407284/how-to-get-multiple-selected-values-of-select-box-in-php>>

Thank you for your kindly reply.

As we know, the names used for the HTML form variables that are submitted are the same as the Name property of the objects.

I could see in the HTML example in the link above:

<form method="post" action="value.php">
           <select name="flower[ ]" size="8" multiple>

Note that the form variable "flower" contains brackets [ ]. This way, PHP at back-end can parse the items submited. If I remove the brackets, I get an PHP error message:

'Invalid argument supplied for foreach() "

The same error when EWB submits TListBox multiple items.

Best regards,
Sergei Safar
Fri, Jul 12 2013 12:54 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Sergei,

<< Note that the form variable "flower" contains brackets [ ]. This way, PHP
at back-end can parse the items submited. If I remove the brackets, I get an
PHP error message:

'Invalid argument supplied for foreach() " >>

This is really a PHP issue.  You should consider using the appropriate PHP
support venues for finding a solution.  The values *do* come through
properly from EWB, and should not require any special naming to work with
the back-end.   Doing so would break other back-ends that don't require
special naming.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jul 15 2013 10:24 AMPermanent Link

Sergei Safar

Hi Tim,

<<Doing so would break other back-ends that don't require special naming.>>

yes, I understand. Anyway, I got a solution using TServerRequest, a loop through TListBox selected items sending each one as a parameter. The back-end did the rest.

Thank you all for the help and hints.

Best regards,
Sergei Safar
Page 1 of 2Next Page
Jump to Page:  1 2
Image