Thank you so much Shlomi!
Hi Shlomi ,
Good day.
Thank you for the kind response to my problem and it was resolve.
And I have one question, sorry to give you so much work, but I badly need your help.
Could you look at this? —> https://www.wix.com/code/home/forum/questions-answers/wix-locatin-is-not-working
Hi Shlomi…Thank you so much! It’s partially working for me… I can record the entry in the field value into my second DB… But I need to update this same entry in the First DB at the same time. I tought keeping button connected to dataset : NEXT ITEM will work at the same time with a onclick event ! Unfortunately not (see next post about this issue)! I want to simplify your code for GEO, I think I don’t need the first part of the code .Here’s my last code : IN BOLD the PART is NOT WORKING
export function button53_click(event, $w) {
let playername = {
“player”: $w(“#input31”).value,
“position”: $w(“#dropdown1”).value,
};
console.log("person to be saved" + JSON.stringify(playername));
wixData.insert("STATS", playername)
.then( (results) => {
let playername = results; //see item below
console.log("person in db: " + JSON.stringify(playername));
wixData.update(“PLAYERS_NAME_IMPORT”, playername)
} )
.catch( (err) => {
let errorMsg = err;
} );
}
URL is : ( page is not finished to setup yet)
https://www.cibledetection.com/players-name-import-position-home
Also… Why when I submited (insert) data with the onclick event, the datas don’t update value in the Table ? I have to refresh the page !
Hi Shlomi… Me again, I made more tests with coding, Something is weird ! I connected a button to dataset (SUBMIT) with this code onclick event attach to the same button :
export function button12_click(event, $w) {
let gteamname = {
“gteamName”: $w(“#input26”).value,
“hteamName”: $w(“#input23”).value,
“gteamPict”: $w(“#uploadButton2”).value,
“hTeampict”: $w(“#uploadButton4”).value,
};
console.log(“person to be saved” + JSON.stringify(gteamname));
wixData.insert(“MATCH_SUMMARY”, gteamname)
}
This code work perfectly, it update datas entry in DB1(with SUBMIT connect dataset) and save all fields onclick event into DB2.
But in the same webpage I have a similar code doing the same thing for a other button, but the SUBMIT connect to dataset to DB1 doesn’t work this time. DB2 onclick event working !? I don’t understand why (it work with the other button and onclick event describe upper) )? If it could work in this way you could ignore my previous post and it would be really more simple! Here’s the second CODE :
export function button54_click_1(event, $w) {
let playername = {
“player”: $w(“#input30”).value,
“position”: $w(“#dropdown1”).value,
};
console.log(“person to be saved” + JSON.stringify(playername));
wixData.insert(“STATS”, playername)
}
Thank you in advance to look at what’s wrong with… -Ronny
URL : https://www.cibledetection.com/players-name-import-position-home
Hi Ron, Geo,
this specific thread is getting to a point it is drifting away from the original question
if i understand correct, we are trying to resolve a simple challenge - if we have 2 db collections 1 referencing the other, how do i best (db/software) design it with wix code.
i also believe Ron and Geo, you have a lightly different challenges.
lets please start two new threads, come up with simple examples that best demonstrate the situation, and then lets write some code to make a simple scenario as you describe working.
makes sense?
Shlomi
Hi Shlomi… From my side, I’m agree! Just let me know thread of this post!
-thank you!
please just create a new question on this forum with the details and specific example.
i’ll try to code a simple site that will help with some code samples. lets please then link it here
I have created a test page for you ! https://www.cibledetection.com/test-2db-records
Hi,
Sorry if I’m slightly late to this thread, but I have a question regarding the code that Shlomi posted above. How do I know what to change for my site to make it match with my data, and not the “person” and “dog”. I’m confused as to what I am supposed to change, and what I leave alone. Thanks! (Sorry if this is a stupid question, but coding is not my thing)
-Pawtalog
This is a copy of the code from above:
import wixData from ‘wix-data’;
export function insertDog(owner, $w){
let dog = {
“id”: $w(“#dogid”).value,
“name”: $w(“#dogname”).value,
“weight”: $w(“#dogweight”).value,
“owner”: owner._id
};
console.log("dog to be saved" + JSON.stringify(dog));
wixData.insert("Dog", dog)
.then( (results) => {
let dog = results; //see item below
console.log("dog in db: " + JSON.stringify(dog));
} )
.catch( (err) => {
let errorMsg = err;
} );
}
export function submitbutton_click(event, $w) {
let person = {
“name”: $w(“#ownername”).value,
“ssn”: $w(“#ownerssn”).value
};
console.log("person to be saved" + JSON.stringify(person));
wixData.insert("Person", person)
.then( (results) => {
let owner = results; //see item below
console.log("person in db: " + JSON.stringify(owner));
insertDog(owner, $w);
} )
.catch( (err) => {
let errorMsg = err;
} );
}
Hi,
I am looking for saving buttons label value into my database. This forum seems to be little bit closer to my issue but not able follow it. Can anyof you please look at my question here:
Hi Or,
I tried to recreate this code in order for a checkbox to save to two databases. Are you able to see where my mistake might be?
Thank you!
Please add your own issue into a new post instead of bumping up an old post.
Also, add any code in a code block (not in screenshots) as stated in the Forum Guidelines.
This post is being closed.