where the user clicks on the required radio buttons, then the idea is to click a submit button. On clicking the submit button, all of the values (text, see below) need to be added together in a comma separated list like…
Replace N/S Front Bumper End Cap, Replace O/S Front Bumper End Cap, Paint N/S Front Bumper End Cap, Paint O/S Front Bumper End Cap
My question is, what do I need to do to get a comma separated list? The list can be in a variable, or in a field input, or directly into a DB. I know how to further manipulate the data from there. I can’t seem to work out how to get my button values into a list. Help please.
This will not answer your question regarding a comma separated list, so please ignore if I am stepping outside of what you want.
I think that you are making it hard for yourself, personally I would have each answer in a separate field type TINYINT and a default value of 0. When the button is populated, the value will change to 1 if the button has a value of 1.
In your output you will show Replace (or nothing) when the value is 0 and Repair if the value is 1.
Hi Ben, I appreciate where you are coming from and I had thought about the basic DB table option. Not that it would be difficult but let me give you a bit more info as your assumptions are not quite right.
There are currently 253 areas or parts on our basic list.
Each of these are then combined with ‘not selected/zero’, ‘replace’, ‘repair’, ‘paint’, ‘blend’ to create the button options that you see.
We can just ignore the zero option but it still leaves a potential for over 1000 options to be selected.
And then there is the issue of the list being added to quite frequently as they fine tune their reports.
So this could be a little awkward to maintain and control, especially when all we need is a list of those selected. I know I could maintain it dynamically in the DB but would like to find a solution as first outlined. Cheers
Oh, and I forgot, there is also the options of N/S and O/S (near-side and off-side), and the options of N/S/F, N/S/R, O/S/F and O/S/R (near-side front, near-side rear etc). So it can be a big list.
I have done something similar (on a much smaller scale), where I have put all of the accessories into a separate database table, this so that the client can add to the number of accessories. The accessories are shown in the admin section where the relevant items are ticked.
The ticked items are inserted into the Caravan table in a comma delimited format. In the public page, only the ticked items are listed.
In the first modal, click on any one of the 12 areas marked and it brings up a second modal with a list of areas or parts of a car in that area of the car that you clicked on. So for O/S (off-side) on the first diagram…
and the columns mean
cp_nesw = car parts _ north east south west [area of car] (the numbers represent 2 door or 4 door)
cp_qty = quantity (ie 1 set of hinges per door)
under cp_replace, cp_repair, cp_paint, cp_blend
1 = yes and 0 = no
When ‘Save changes’ is submitted you then get the following result in DevTools which shows the name and value in the submitted form
The ‘1_’ and ‘2_’ at the beginning of the name represent ‘Replace’ or ‘Repair’
Then group all the 1s together and 2s together
And finally concatenate the values separated with comma and space, and with a fill stop at the end. These values are then inserted into DB columns “Replace” and “Repair”
@UKRiggers i am not entirely sure what exactly do you need to achieve, but in server connect you can return all the submitted POST values under by selecting {{$_POST}} as an expression …
On the server you get directly the correct arrays, like when Door and Loading Door the repair are checked. On the server you get $_POST["repair"] = ["Door", "Loading Door"].
You can style the checkboxes as buttons, by style something like:
I agree and it would be simpler, BUT we have to ensure that the user does NOT select both “Replace” and “Repair”. It is one or the other. Hence the reason for using radio buttons.
Or can you suggest an easy way to prevent both being checked?
Patrick, thanks again for your time. You have given me plenty to work with, and I will rework what I have. It is not much work to do as it is all dynamic.
Once again I have probably been overthinking the whole issue and the simple option is always the best
Hi Patrick, carrying on this conversation, I am struggling with this 'dmx-on:change' to work with multiple dynamic checkboxes
For instance I have the following in a form. There are, in this small example, 8 checkbox groups, each created dynamically with a varying number of checkboxes. I did have them ad radio buttons but am in the process of changing them based on our conversations last week.
My code for the first one is as follows (I am yet to change to checkbox)
Checkboxes are used when a field has multiple values, if I see the screenshot then this seems more like a radio group. So what is the output that you expect?