Dynamic Radio Buttons Update Database


So I have created a ServerConnect that gets a list of programs that a user might have access to. There is a status column (1=On, 0=Off). In the page I have created a simple container followed by a Repeat that is linked to the serverconnect1. Within the Repeat I have a Horizontal Form Group that contains a a Radio Control. There is a radio for the On and one for the Off. Now this is the tricky part, since the Repeat is creating the radio groups dynamically when it comes time to update the database with the user’s selection, how do you process the $_POST values when the radio groups are dynamically created?

Test Page: https://ewlusa.org/theportal/TEST_radios.php

Any help is greatly appreciated.

First off, I do not see a FORM element or a submit button. Secondly, the $_POSTed values come from the NAME attribute which in your example are left empty,

Ben, thanks for starting to take a look at this. You are correct, there is no FORM element or a submit button. I pulled the radio repeat out of a much larger page to figure out how to even display the radios since they very based on the data pulled from the database.

As for the NAME attribute, I see when “viewing the source code” that the field is blank. But there is also a dmx-bind:name=“id” where “id” is a value coming in from the serverconnect. When you “inspect element” in the browser for one of the radio groups you can see the actual id value in the code.

So, my concern is how to process the radios when I would submit a form since they NAME value for a radio would be different for each potential serverconnect call.

We get an error when opening your page…

dmxAppConnect.js:7 GET https://ewlusa.org/theportal/dmxConnect/api/admin/admin_get_user_appaccess.php?app_user_id=2&app_chapter_id=1 401 (Unauthorized)

Sorry about that, I turned the security provider off for that server connect. Should be able to load the page now.

You should really put a FORM element and a SUBMIT button. Then you can look at DevTools when you submit to see what is sent in the POST.

Also, how is your database set up?

Then you can decide how to process the POST and map the fields.

So, took your advice and added a form and submit button. The form submits to a simple PHP page that just has a var_dump of the POST variable. This results in what I expected, the values of all of the selected radios each represented by the ID of the record in the database.

Database is a MySQL table with the following columns: id, userid, appid, app_status

Well, I think I have found some of the solution. I changed the dmx-bind:name to the following:


That gets me an array loaded to the “record” variable that gets passed to $_POST.

Now the question is how do I access the array in a serverconnect Database Multi-Update? My $_POST data looks like:

1apost.php:4: array (size=1) ‘record’ => array (size=9) 0 => array (size=1) 42 => string ‘0’ (length=1) 1 => array (size=1) 38 => string ‘0’ (length=1) 2 => array (size=1) 43 => string ‘1’ (length=1) 3 => array (size=1) 37 => string ‘1’ (length=1) 4 => array (size=1) 40 => string ‘1’ (length=1) 5 => array (size=1) 45 => string ‘1’ (length=1) 6 => array (size=1) 44 => string ‘1’ (length=1) 7 => array (size=1) 39 => string ‘1’ (length=1) 8 => array (size=1) 41 => string ‘1’ (length=1)

I need to loop through this and do updates. Any ideas?