hi,
how to integrate in the same form records of two different databases in the same, form in the same page !!! ( data and form )
hi,
how to integrate in the same form records of two different databases in the same, form in the same page !!! ( data and form )
Are you trying to create data for 2 different databases in one form?
as i am not a wix expert or have any relation with coding, just like a random person with 0 coding knowledge i would probably try these:
create a button in front of the submit button and hide it on load
Set submit button to “stay on this page” after submitting
Create a success message and set a onViewportEnter event on this message to hide submit button and show the new button
Link that button you created whereever you want to go after submitting
Create an onclick event for that new button and put to following code:
$w('#your2nddataset').setFieldValue('fieldKeyAsIn2ndDatabase', $w('#yourinput').value);
If everything goes well this should work IMO
Hello
Thank you for your example … I will experiment this.
But I show you my problem… how can i make it to include in my report before or after sending a reference from another database in this form.
include a value (database 1) in a form and add in the same form a value from another database (database2)
If you could show it an example with the code … Thank you for your help !!!
Oh i see… so this is the dynamic page of database1 items and you want to collect data on that dynamic page for database2…
You can just duplicate the first picture, resize it to a smaller size and move that duplicate near the form whereever you want.
After that just add a new dataset and connect your input elements to it. No need to do anything else
Ah ok i see, but I dont know JS…Could you show me a example with a specific code ?
thank you very much .
I don’t know either But there’s no code included in this setup you can do all these in the editor.
You may want to add product id to your form though and you have to pull that value from the dynamic page itself. Else it would be a random data coming from a random location.
Let’s say this is a product and the form is to collect interest from customer.
In order to do that you will need to display the title or the name of the product somewhere on your dynamic page as it is connected to your dynamicDataset (Database1)
You just need this code to do that
$w('#your2nddataset').setFieldValue('#fieldKeyAsIn2ndDatabase', $w('#yourproductname').value);
your2nddataset: is the dataset where you will be collecting this information (id of your 2nd dataset)
fieldKeyAsIn2ndDatabase: is the field where you want this data to go. (In this example you may want to add a new field and name it as product so whenever someone fills out this form you will know which product this form is about)
yourproductname: is the element where you show this product (title-name-id whatever you name it) on your dynamic page. It is connected to your dataset1 as title-name-id etc. you set it.
The way i use it is this:
$w('#dataset1').setFieldValue('username', $w('#username').value);
dataset screen shot
User input is where i get the info of the user. In your case it’s going to be your items name $w(“#nomDeDeuvre”).value
On my example #username is a part of my form which is hidden somewhere on the screen cause whoever fills out this form doesn’t have to see it.
And finally fieldkey is the field that you are going to add that information in your database as it is “username” in my example.
Field Key screen shot
#userinput screenshot
This all should be under an event like your submitbutton’s onclickEvent
There shouldn’t be space in your dataset name check your dataset name.
no space again… it’s $w(“#dataset”).setFieldValue(“field”, value);
It’s either ’ or " not both of them
Hello
Thanks a lot for your help !!!
I understood the syntax of the function, but when I test the function there is a problem on the console
Message is " Error: The element selector function (usually $w) cannot be used before the page is ready "
I removed “.value” and after all was Ok, but there was always the error message in the console …
" Error: The element selector function (usually $w) cannot be used before the page is ready "
My function is: $w(‘#dataset1’).setFieldValue(‘title’, $w(‘#text11’));
A big big thank you for your help !!!
Hi,
You need to wrap it with onReady function.
It should look like this:
$w.onReady(() => {
$w('#dataset1').setFieldValue('title', $w('#text11'));
});
Roi
Hi Roy,
I reloaded the code with your example …
$w.onReady(() => { $w('#dataset1').setFieldValue('title', $w('#text11')); });
Message:
DatasetError: The dataset didn’t load yet. You need to call setFieldValue inside the onReady for the dataset.
I changed the code I do not know how to program in JS !!!
$w.onReady( function() {
$w('#dataset1').setFieldValue('title', $w('#text11'));
});
Same Message:
DatasetError: The dataset didn’t load yet. You need to call setFieldValue inside the onReady for the dataset.
I have remodified the code … It’s OK but the result in the database is not good
$w.onReady( () =>{
$w("#dataset1").onReady(() => {
$w('#dataset1').setFieldValue('title', $w('#text11'));
});
});
[object Object] ??? how to replace that by the good value ?
Pierre
Hi,
You are right about this:
$w(" #dataset1 ").onReady
This is the correct one:
$w.onReady( () =>{
$w("#dataset1").onReady(() => {
$w('#dataset1').setFieldValue('title', $w('#text11').text);
});
});
Roi
Thanks a lot ROI and Mert Ömer for your help !!! everything is working …
Best regards !
Pierre
Hi,
How insert a image in my dataset with setFieldValue.?
$w.onReady( () =>{
$w("#dataset1").onReady(() => {
$w('#dataset1').setFieldValue('title', $w('#text11').text);
});
});