Need your help in deleting selected rows from a repeat table. I have included checkbox and its value when checked is stored in an array. The checkbox values are the IDs of the rows to be deleted.
I am unable to remove the IDs from the array if the checkbox is again deselected after initial selection.
I suppose you want to delete multiple records based on the checkbox cjecked/unchecked... If I'm correct then you should work like Teodor suggested here:
Inside your formRepeat you will include a hidden input of the Journal_id and the select checkbox input. BOTH OF THEM WITH dynamic ids (dmx-bind:id).
Then on Del Journal click, in your serverconnect_form, you add a repeat based on your page's formrepeat and check if checkbox (upd_delJournal.value==1) then delete the current record.
**Just for safety, instead of deleting the record, add a setValue with the current journal_id and output it.
So when you run ir in your browser, on "Del Journal" click you will be abvle to see if the correct ids are outputed. Then you will be safe to replace the setValue with the final DB Delete procedure.
You can do this with a form repeat like @famousmag says or you can send the values (1,2) and then on the server connect use a repeat with split (with comma ,) then you use the repeat id to delete the record
PS: Remember to do some backup specially working with deleting records
@famousmag I am sorry for bothering you again, however, i am confused about creating the server connect.
The table is already a part of form repeat & i have an existing server connect to update the main & sub table.
In this scenario, i am unable to understand how to create a server connect which will get the check box values for deleting the rows.
I have understood that by clicking the Del Juarnals button, you want ALL the Journals with the checkboc checked to be deleted... IS THIS WHAT YOU WANT TO DO?
If yes, then have you implement this Teodor's solution from your previous topic?
If you have, then on your serveraction, by assigning the page and the form (that includes the formrepeat) if you click the import from form button, an array will be automatically created in your input $_POST containg the 2 variables , jurnal_id and checkbox_selected
Then add a repeat step based on the $_POST formrepeat and in there check if the checkbox_selected .value==1 then delete the record
As I told you, Instead of deleting the record, add a setValue isDeleted = juarnal_id and check the output.
This way when you run the page and click the Del Juarnals button, you will get on your dev network tab the ids of the Journals to be deleted...
When you are sure that it is working fine, replace the setValue with the DB delete step