Checkbox value combined - won't save to database?

I can’t get combined text to create an entry to my dataset upon submission of the form.
Please Help,
I have a custom form laid out over a slideshow using most user input elements.
The form works well.
I have one slide dedicated to the user selecting checkboxes.
I want to save their input as a string of text in a hidden textbox so its only one input rather than lots of Boolean ticks.
I have successfully coded this action as follows :-
$w.onReady(function () {
$w(“#checkbox20”).value = ‘’;
$w(“#checkbox19”).value = ‘’;
$w(“#checkbox31”).value = ‘’;
$w(“#checkbox24”).value = ‘’;
$w(“#checkbox18”).value = ‘’;
$w(“#checkbox21”).value = ‘’;
$w(“#checkbox23”).value = ‘’;
$w(“#checkbox30”).value = ‘’;
$w(“#checkbox26”).value = ‘’;
$w(“#checkbox25”).value = ‘’;
$w(“#checkbox22”).value = ‘’;
$w(“#checkbox29”).value = ‘’;
$w(“#checkbox28”).value = ‘’;
});
export function checkbox19_click(event, $w) {
blues();
}
export function checkbox20_click(event, $w) {
pop();
}
export function checkbox31_click(event, $w) {
swing();
}
export function checkbox24_click(event, $w) {
reggae();
}
export function checkbox18_click(event, $w) {
country();
}
export function checkbox21_click(event, $w) {
jazz();
}
export function checkbox23_click(event, $w) {
rock();
}
export function checkbox30_click(event, $w) {
worldBeats();
}
export function checkbox26_click(event, $w) {
oddMeters();
}
export function checkbox25_click(event, $w) {
funk();
}
export function checkbox22_click(event, $w) {
rocknroll();
}
export function checkbox29_click(event, $w) {
hardrock();
}
export function checkbox28_click(event, $w) {
heavymetal();
}
function blues() {
if ($w(“#checkbox19”).value === ‘’) {
$w(“#checkbox19”).value = ‘Blues,’;
}
else {
$w(“#checkbox19”).value = ‘’;
}
}
function pop() {
if ($w(“#checkbox20”).value === ‘’) {
$w(“#checkbox20”).value = ‘Pop,’;
}
else {
$w(“#checkbox20”).value = ‘’;
}
}
function swing() {
if ($w(“#checkbox31”).value === ‘’) {
$w(“#checkbox31”).value = ‘Swing,’;
}
else {
$w(“#checkbox31”).value = ‘’;
}
}
function reggae() {
if ($w(“#checkbox24”).value === ‘’) {
$w(“#checkbox24”).value = ‘Reggae,’;
}
else {
$w(“#checkbox24”).value = ‘’;
}
}
function country() {
if ($w(“#checkbox18”).value === ‘’) {
$w(“#checkbox18”).value = ‘Country,’;
}
else {
$w(“#checkbox18”).value = ‘’;
}
}
function jazz() {
if ($w(“#checkbox21”).value === ‘’) {
$w(“#checkbox21”).value = ‘Jazz,’;
}
else {
$w(“#checkbox21”).value = ‘’;
}
}
function rock() {
if ($w(“#checkbox23”).value === ‘’) {
$w(“#checkbox23”).value = ‘Rock,’;
}
else {
$w(“#checkbox23”).value = ‘’;
}
}
function worldBeats() {
if ($w(“#checkbox30”).value === ‘’) {
$w(“#checkbox30”).value = ‘World Beats,’;
}
else {
$w(“#checkbox30”).value = ‘’;
}
}
function oddMeters() {
if ($w(“#checkbox26”).value === ‘’) {
$w(“#checkbox26”).value = ‘Odd Meters,’;
}
else {
$w(“#checkbox26”).value = ‘’;
}
}
function funk() {
if ($w(“#checkbox25”).value === ‘’) {
$w(“#checkbox25”).value = ‘Funk,’;
}
else {
$w(“#checkbox25”).value = ‘’;
}
}
function rocknroll() {
if ($w(“#checkbox22”).value === ‘’) {
$w(“#checkbox22”).value = ‘Rock n Roll,’;
}
else {
$w(“#checkbox22”).value = ‘’;
}
}
function hardrock() {
if ($w(“#checkbox29”).value === ‘’) {
$w(“#checkbox29”).value = ‘Hard Rock,’;
}
else {
$w(“#checkbox29”).value = ‘’;
}
}
function heavymetal() {
if ($w(“#checkbox28”).value === ‘’) {
$w(“#checkbox28”).value = ‘Heavy Metal,’;
}
else {
$w(“#checkbox28”).value = ‘’;
}
}
function valueCombine() {
let checkedValue = $w(“#checkbox18”).value + " " + $w(“#checkbox19”).value + " " + $w(“#checkbox20”).value + " " + $w(“#checkbox21”).value+ " " + $w(“#checkbox22”).value + " " + $w(“#checkbox23”).value + " " + $w(“#checkbox24”).value+ " " + $w(“#checkbox25”).value + " " + $w(“#checkbox26”).value + " " + $w(“#checkbox28”).value + " " + $w(“#checkbox29”).value + " " + $w(“#checkbox30”).value + " " + $w(“#checkbox31”).value;
$w(“#textBox1002”).value = checkedValue;
}
export function next5_mouseIn(event, $w) {
valueCombine();
}
It seems to work well.
I haven’t hidden the combined value textbox so i can see progress in preview mode.
(screen shots attached)
The problem I am having is -
The text that shows in combined box is not saving to my database???
It is defiantly correctly attached as if i manuals type an entry it is saved.
All I can presume is that Wix does not support this form of data entry as user input??
do I have to add a command to complete the required action?
Is it possible??
Help please

The text box where you have pop and so on, which field in the data collection is that connected to?

A field named - Genre - specified as text.
If I manually type in the box it does save the text typed on submission of the form?

Ok you have want for the valueCombine to be ready before Saving to data collection.

Yes, how do I do it?
Am I missing a command in my coding?

Have I missed something?
Please help…
It’s sending me mad! Lol :stuck_out_tongue_closed_eyes:

Anyone found a solution for this? please, thanks!

Hi,

In addition to setting the appropriate text box, you also need to use the dataset’s setFieldValue() function:

$w("#textBox1002").value = checkedValue;
$w("#dataset1").setFieldValue("checks", checkedValue);

I hope this helps,

Yisrael

You are an absolute star!!!
That little line of code has worked , thank you .

1 Like

:tada: