Can someone take a look at this code?

I can’t seem to get this code working properly. I want it to, after clicking the done button, search dataset for gender and number of items. If gender = male and number of items < 6, it should take you to a page called male-basic. And for the 3 others as seen in the code. There are no errors but it is not sending to the correct page. Please help, thanks!

import wixData from ‘wix-data’ ;
import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;

export function done_click(event) {
// Add your code for this event here:
$w( “#dataset2” ).onReady( function () {
function myFunction() {
let gender = “male” ; // change to “male” run the code again and see results in the CONSOLE.
let numberofitems = 5 ;
wixData.query( “#dataset2” )
.eq( “gender” , “male” )
.find()
.then( (results) => {
if (results.gender === “male” && results.numberofitems < 6 ) {

            wixLocation.to( "/Men-Basic" ); 
            console.log( "Male-BASIC-activated" ); 
        }  **else**  { 
            wixLocation.to( "/Men-Advanced" ); 
            console.log( "Male-ADVANCED-activated" ); 
        } 

if (results.gender === “female” && results.numberofitems < 6 ) {
wixLocation.to( “/Female-Basic” );
console.log( “Female-BASIC-activated” );
} else {
wixLocation.to( “/Female-Advanced” );
console.log( “Female-ADVANCED-activated” );
}
}
);

}

    } 
); 

}

Aha, here we go again :grin:

I’ve done a lot to the code and it should work! :joy:

@ngafney07
Yes i see the progress, but still do not work.

  1. First question!
    Do you set your variables manually in the code? Why?
let numberofitems = 5;

@russian-dima Yes, I was following the wix corvide reference website

do you know how to make it work @russian-dima ?

@ngafney07
Check this out and forget your CODE :grin:

import wixData from 'wix-data';

$w.onReady(function () {})


export function dropdown1_change(event) {myFilter(), console.log($w('#dropdown1').value)}


function myFilter () {console.log("Filter-process started")
 
    wixData.query("Male-Female")
 
    .eq("gender", $w('#dropdown1').value)
    .find()
    .then( (results) => {
 if(results.items.length > 0) {
 let firstItem = results.items[0]; 
 let items = results.items
        console.log(items)

        $w('#table4').rows = results.items

        } else {
 // handle case where no matching items found
        }

And here you have an life example…

https://russian-dima.wixsite.com/meinewebsite/male-female

But i did not implement all functions.
Now it’s your turn to complete this and implement the second function, with the TYPE-NUMBER (1-10).

I have also turned off the search-button, if you want it to search it by pressing the SEARCH-BUTTON, you can change the CODE, but i think this VERSION is a little bit more comfortable.:grin:

P.S.: This example works absolutely DATASET-FREE ! ! ! No dataset needed!

@russian-dima That looks similar to what I want but that’s I guess to a next level maybe? I don’t need the drop down of male/female and number of items. It will take that information from the dataset where that info is already there. I just need to click the button and it sees, ok, male and 7, go to the male-basic page

And I need the data set because the info that the quiz gets which then sends to the buy page must be used for customer records. The database holds information like name, email, clothing sizes, etc. I need this information for the product and shipping.

@ngafney07
Oh man xDDDD, you should better give more details and say if you are using DYNAMIC-PAGES ? DO YOU ?

Show me a part of your database-structure.

I don’t need the drop down of male/female and number of items. It will take that information from the dataset where that info is already there.
Shwo me also the CODE, which already gives the results for GENDER and the TYPE-ID.

You can also use GLOBAL-VARIABLES and then the problem is solved.

Show me a pic of the relevant site, then i can imagine better, what you are trying to do.

@russian-dima Would it be easier to invite you as a contributer? That way you can get a real feel of what I am trying to do?

@ngafney07
Hello again,

could you solve your problem in the meanwhile?