HTML5 Data Bindings Formatter Support Product Page
Answered
How can I take a multiple select form and create a comma separated array from the options?
Asked 21 Apr 2017 16:52:47
1
has this question
21 Apr 2017 16:52:47 Bobby Edgar posted:
Like the old implode/explode functions in PHP? example: id="something[]" Replies
Replied 24 Apr 2017 07:34:26
24 Apr 2017 07:34:26 Teodor Kuduschiev replied:
Hello Bobby,
What do you need to achieve - to store the selected values as a comma separated list in a single database field?
What do you need to achieve - to store the selected values as a comma separated list in a single database field?
Replied 24 Apr 2017 08:54:43
24 Apr 2017 08:54:43 Bobby Edgar replied:
Yes. That's exactly right.
Just like I can using PHP/MYSQL:
I need to do the exact same thing with DataBindings, but can't figure it out.
Just like I can using PHP/MYSQL:
<select name="a_set_of_values[]" multiple id="a_set_of_values"> <option value="Value_1">Value_1</option> <option value="Value_2">Value_2</option> <option value="Value_3">Value_3</option> <option value="Value_4">Value_4</option> <option value="Value_5">Value_5</option> </select>
$Valuestochoose = implode(',',$_POST[a_set_of_values]);
$sql = "INSERT INTO a_table (some_field) VALUES ('$Valuestochoose)";
I need to do the exact same thing with DataBindings, but can't figure it out.
Replied 24 Apr 2017 09:23:40
24 Apr 2017 09:23:40 Teodor Kuduschiev replied:
But selecting {{$_POST.a_set_of_values}} as a value in the insert record step, should do exactly this.
Replied 24 Apr 2017 15:44:48
24 Apr 2017 15:44:48 Bobby Edgar replied:
I thought that too, but when I add the brackets [] to the select name, the form doesn't add the data at all and it doesn't throw an error.
This is extremely frustrating.
This is extremely frustrating.
Replied 24 Apr 2017 15:54:31
24 Apr 2017 15:54:31 Teodor Kuduschiev replied:
Please provide a link to your page where i can check the issue.
Replied 25 Apr 2017 00:33:55
25 Apr 2017 00:33:55 Bobby Edgar replied:
Hello Teodor,
I've created a sample page with 2 forms. One is the PHP version and scripting that works, and the other is setup using DMX Data Binding.
The PHP form allows you to multi-select and it creates a comma separated array and places those values into a field in the database.
The DMX Data Bindings form only inputs the last selection made. It does not create the array that I need.
Your help is greatly appreciated.
-Bobby
Sample Link:
faces.vegas/DMX_DB_HELP.php
I've created a sample page with 2 forms. One is the PHP version and scripting that works, and the other is setup using DMX Data Binding.
The PHP form allows you to multi-select and it creates a comma separated array and places those values into a field in the database.
The DMX Data Bindings form only inputs the last selection made. It does not create the array that I need.
Your help is greatly appreciated.
-Bobby
Sample Link:
faces.vegas/DMX_DB_HELP.php
Replied 25 Apr 2017 06:30:24
25 Apr 2017 06:30:24 Teodor Kuduschiev replied:
But your DMXzone example's select does not have [] in the name:
It must be:
<select name="dmx_sample" multiple id="dmx_sample">
It must be:
<select name="dmx_sample[]" multiple id="dmx_sample">
Replied 25 Apr 2017 11:42:24
25 Apr 2017 11:42:24 Bobby Edgar replied:
Like I said before, when I add those brackets, the form doesn't add anything to the field. I made that change in an example to show you what I mean.
No Brackets: faces.vegas/DMX_DB_HELP.php
With Brackets: faces.vegas/DMX_DB_HELP_with_brackets.php
No Brackets: faces.vegas/DMX_DB_HELP.php
With Brackets: faces.vegas/DMX_DB_HELP_with_brackets.php
Replied 25 Apr 2017 12:02:02
25 Apr 2017 12:02:02 Teodor Kuduschiev replied:
That is why i wanted to check ...
Please:
1. Remove the go to url behavior, on complete
2. Enable debug mode in server connect so i can see the exact error message
Please:
1. Remove the go to url behavior, on complete
2. Enable debug mode in server connect so i can see the exact error message
Replied 25 Apr 2017 22:20:49
25 Apr 2017 22:20:49 Bobby Edgar replied:
Replied 27 Apr 2017 07:03:40
27 Apr 2017 07:03:40 Teodor Kuduschiev replied:
Hi Bobby,
I tested that, and this kind of insert requires the use of server data formatter. You need to add this, as an insert value: {{$_POST.a_set_of_values.join(",", null)}}
I tested that, and this kind of insert requires the use of server data formatter. You need to add this, as an insert value: {{$_POST.a_set_of_values.join(",", null)}}
Replied 27 Apr 2017 11:45:30
27 Apr 2017 11:45:30 Bobby Edgar replied:
Perfect! Thank You, Teodor.