How select records from a multiple record form flagging row specific check box field

Hi all,

I have to select some records from a multiple record form.
I have, in the same time, to hide all buttons like update insert cancel etc. becouse I need that user do not update records but only select a part of them only flagging a match box field.
I added in front of each row a ‘selec_record’ check box field that has to be used by users to select some rows only.
Once selected the rows I need to transform the selection into a select of table like the following (mind that select_record is not a table field…)
SELECT field1, field2…, field_n FROM TABLE where select_record = 1
Is it possible in a simple way ?
I added a header form button but I don’t know how intercep the selected rows becouse the field is not of table fields.
Many thanks

See image

PS I saw than once upon a time there was a kind of button called ‘run’ but it’s all deprecated now and also not so easy to understand.

sel.jpg

The Run button is available on grids but here is an implementation similar to it for a form.

OK, let’s go.

Define a global array in the onLoad event: [selected] = array(); //mark it as out

Initialize the array in the onLoadRecord event: [selected][{id_field}] = 0; // array of the loaded id’s of the page

Create an onClick ajax-event on your {select_record} field: [selected][{id_field}] = {select_record}; //select/unselect a record

Create a PHP button with the following code:

foreach (array_keys([selected], 0, true) as $key)
{
unset([selected][$key]); //get rid of the unselected id’s
}
$selection = implode(’,’,array_keys([selected])); // now you have a comma separated list of id’s of your selected records

Cool, eh?

jsb

As Always many thanks !!
Due to the fact that checkbox field is not on table it seems that SC is not able to read the id of record selected .
What I see is that {select_record} could be 0 as default and 1 when selected so the [selected][{id_partner}] result ‘undefined’
Also the last echo of $selection is --> undefined.

I did the following
OnLoad : [selected] = array();
OnLoadRecord : [selected][{id_partner}] = 0; // array of the loaded id’s of the page
select_record_onClick : [selected][{id_partner}] = {select_record}; //select/unselect a record

Button :
foreach (array_keys([selected], 0, true) as $key)
{
unset([selected][$key]); //get rid of the unselected id’s
}
$selection = implode(’,’,array_keys([selected])); // now you have a comma separated list of id’s of your selected records
echo $selection;

Did you set the LookupSettings for your checkox?
jsb

checkbox.jpg

Yes, I did it yet previously.

Is the {id_partner} field on the form? It can be hidden though.
{select_record} doesn’t have to be part of the table. Just a custom field.

Unfortunately I don’t still have the list of selected key fields

Hi,
on attached doc there are the steps done.
How can I see the selected key fields ?

[QUOTE=jsbinca;21073]Is the {id_partner} field on the form? It can be hidden though.
{select_record} doesn’t have to be part of the table. Just a custom field.[/QUOTE]

Hi there.
I have a very similar issue.
Got a simple form that has a checkbox called “romancode” and an input field called “price”.
There is row after row of these.

At the bottom, is a button to submit. So I want to check only those I wish to process, and click submit.
On the following page in a foreach loop, I want to query the romancode, and insert that, with items found from a database, along with the passed-over price from that field.

In other words: I want to select that product, that product, not that one, not that one, and that one. And I want to set that price to that… and so on. Hit submit. And each of those selected are dealt with.

I can make this all work, so it submit everything, but I cannot make it only process the prices for the romancode checkboxes I have ticked.

<form method='post' action='/a_products&u=copy'>
        <td>89.99</td>
        <td><input type='text' style='width: 60px; text-align: right' name='price[]' value='108.00' id='108.00'> ?</td>
        <td><input type='checkbox' name='romancode[]' value='G5KRED' id='G5KRED'>Select</td>
        </tr>
        
        <tr>
        <td>99.99</td>
        <td><input type='text' style='width: 60px; text-align: right' name='price[]' value='120.00' id='120.00'> ?</td>
        <td ><input type='checkbox' name='romancode[]' value='M86A' id='M86A'>Select</td>
        </tr><tr>
        <td>89.5</td>
        <td><input type='text' style='width: 60px; text-align: right' name='price[]' value='107.00' id='107.00'> ?</td>
        <td><input type='checkbox' name='romancode[]' value='M901C' id='M901C'>Select</td>
        </tr><tr><td colspan='6' align='right'><input type='submit' value='Submit All'></form>