I am desperate now after having tried for two weeks to register both “gender” (Man or Woman) and “genderIcon” (image) from a dropdown element named “gender”. I have added links as values for Man and Woman in the element itself and these links refer to images for respective gender. These values are nicely registered together with all the other stuff when a new user signs up BUT my frustrating problem is that the gender label (Man or Woman) isn’t registered in the “gender” field. Can someone please tell me what I have to add to this code to also register the users gender with text? It shall not be necessary with an extra button.
As you can see I have written “gender” above “genderIcon” but as it is now the current image link also goes to the gender field (shall only show up in the genderIcon field). I have tried with “.label” after $w ( ‘#gender’ ) instead of “.value” but that didn’t work. I also tried with different kinds of queries but that seems hopeless because I get red markings every time and the gender label still refuse to be displayed:
import { currentMember , authentication } from ‘wix-members’ ;
import wixLocation from ‘wix-location’ ;
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
$w . onReady ( function () {})
function valuesValid ( ) {
return $w ( ‘#email’ ). valid &&
$w ( ‘#password’ ). valid &&
$w ( ‘#forename’ ). valid &&
$w ( ‘#age’ ). valid &&
$w ( ‘#gender’ ). valid &&
$w ( ‘#orientation’ ). valid &&
$w ( ‘#country’ ). valid &&
$w ( ‘#language’ ). valid &&
$w ( ‘#nickname’ ). valid &&
$w ( ‘#state’ ). valid ;
}
function register ( ) {
**if** ( valuesValid ()) {
**let** email = $w ( '#email' ). value
**let** password = $w ( '#password' ). value
authentication . register ( email , password )
. then (( user ) => {
**const** toInsert = {
"_id" : user . member . _id ,
"_owner" : user . member . _id ,
"loginEmail" : email ,
"password" : password ,
"firstName" : $w ( '#forename' ). value ,
"nickname" : $w ( '#nickname' ). value ,
"gender" : $w ( '#gender' ). value ,
"genderIcon" : $w ( '#gender' ). value ,
"age" : $w ( '#age' ). value ,
"sexualOrientation" : $w ( '#orientation' ). value ,
"country" : $w ( '#country' ). value ,
"state" : $w ( '#state' ). value ,
"language" : $w ( '#language' ). value ,
}
// add the item to the collection
wixData . insert ( "Members" , toInsert )
. then (( item ) => {
**if** ( wixUsers . currentUser . loggedIn ) {
wixLocation . to ( `/members/account/ ${ item . _id }`);
} **else** {
**let** email = $w ( '#email' ). value ;
**let** password = $w ( '#password' ). value ;
wixUsers . login ( email , password ). then (() => {
wixLocation . to ( `/members/account/ ${ item . _id }`);
}). **catch** (( err ) => {
console . error ( err );
$w ( '#errorMessage' ). text = "Couldn't log you in: " + err
errorMessage ()
})
console . log ( "User is logged in" );
}
})
. **catch** (( err ) => {
console . error ( err );
$w ( '#errorMessage' ). text = "Something isn't right on your end: " + err
errorMessage ()
});
})
} **else** {
$w ( '#errorMessage' ). text = "Something isn't right on your end: There's an Invalid or Missing Property"
errorMessage ()
}
}
function errorMessage ( ) {
$w ( ‘#errorMessage’ ). show ()
$w ( ‘#errorMessage’ ). expand ()
$w ( ‘#regButton’ ). enable ()
$w ( ‘#regButton’ ). label = ‘Register’
setTimeout (() => {
$w ( ‘#errorMessage’ ). hide ( ‘fade’ )
}, 10000 )
setTimeout (() => {
//$w(‘#errorMessage’).collapse() ← Collapse if you want
}, 10500 )
}
export function regButton_click ( event ) {
register ()
}