Storing a button to a collection

Hi There!
I’m trying to create a multi-page form, and I want to “store a button” in my collection.
Particularly, I have a few plans (each “plan” is a container box) on this page - on each plan there is a button, and I want to store the plan that the user has selected in my collection.
I have added a “plan” input field (text) which is set to ‘hidden’ on load, and set its input accordingly using onClick() handler. Meaning, once the button is clicked, the ‘plan’ input field value changes according to the plan that was clicked. (the input field is also connected to the collection)
I have tried to do the same with onMouseIn() instead of onClick(), but it also didn’t work.
Once one of the buttons is clicked I am redirected to the next page in the funnel, which is good, but there is no entry in the collection.
On every other page in the funnel I have managed to store the data, but not on this page.
Any ideas? I am thinking that it might be connected to the fact that I have more than one submit button on one page (is it even possible?)
Are there more efficient ways to store the selected plan according to the button that is being clicked?

Thank you in advance!

$w.onReady(()=>{
    $w('Button').onClick((event)={
        console.log(event.target.id)
    })
})

Hi Dima,
The logging works, but still no entry.

You do not give enough input to work with.

You should describe your situation better.

  1. Do you use a DATASET?
  2. Which entry do you talk about?
  3. Do you use a DATABASE?
  4. Perhaps a Screenshot of what you have in front of your eyes?
  5. Do you use dynamic page?

I can not see your project (site) i just can imagine how it could be.

Why you do not use MULTISTATE-BOXES? Wouldn’t it be much easier?

@russian-dima Hi Dima,
Apologize for the lack of details.
Here are the described plans:

This is a form that is part of a multi-page-form, hence the formID is set to hidden. Each one of the “Select” buttons is a submit button, and I want to be able to save the value “Starter”/“Professional” to my collection when one of them is clicked, and then redirect to the next page in the form.
Here is a screenshot of the button configuration (both are connected to a DB called “Full Funnel”):


And the label of the button is not connected to anything.

I tried to accomplish it by creating an input text field, “Plan”, which is set to hidden, and once a button is clicked - replace its value with “Starter”/“Professional” accordingly.
Here is a snap of the code in the front (I also tried with hover as you can see):


$w.onReady(function () {
 // $w("#starterButton").onMouseIn(() => {
 //  $w("#planInput").value = "Starter";
 // });
 // $w("#professionalButton").onMouseIn(() => {
 //  $w("#planInput").value = "Professional";
 // });
    $w("#starterButton").onClick((event) => {
        $w("#planInput").value = "Starter";
        console.log(event.target.id);
    });
    $w("#professionalButton").onClick((event) => {
        $w("#planInput").value = "Professional";
        console.log(event.target.id);
    });
 
    });
});

As I told you, once I click the button the log is shown in the console successfully and I am redirected to the next page, but nothing is saved into my DB.

Thank you

I think it is related to the fact that I have two submit buttons, cause if I delete one of them the data is saved to my DB…

Delete both buttons and do it manualy with code, thats the best way!

Since you are using a DATASET, all what you will need for your aim, you will find here…
https://www.wix.com/velo/reference/wix-dataset/dataset

Hey Dima, this is what I did eventually and it worked. Thank you!

1 Like

@dorhason3 This is an example where i always have to say, that using code, gives you much more flexibility.:wink: