Something like this:
let dropdownValue;
$w.onReady(function () {
$w("#dropdown1").onChange((event) => {
dropdownValue = event.target.value;
});
});
Something like this:
let dropdownValue;
$w.onReady(function () {
$w("#dropdown1").onChange((event) => {
dropdownValue = event.target.value;
});
});
Will it work?
import wixUsers from 'wix-users';
import {assignRole} from 'backend/role';
$w.onReady(function(){
$w('#register'). onClick(function (){
let email = $w("#email"). value;
let password = $w("#password"). value;
let first = $w("#fname"). value;
let last = $w("#lastName"). value;
let dropdownValue;
$w.onReady(function () {
$w("#dropdown1"). onChange((event) => {
dropdownValue = event. target. value;
});
});
wixUsers. register(email, password, {
contactInfo: {
"firstName": first,
"lastName": last
}
})
.then((results) => {
let roleId="dropdownValue";
assignRole(roleId, results. user. id);
}
)
}
)})
Your new code has many errors. You have a page onReady() function inside of an onReady() function which is incorrect, you are not handling the Promise returned by assignRole(), and other errors.
You will need to spend some time learning how to program in Velo and how the APIs work. To learn about programming with Velo, read the following articles that will help you start working with Velo:
About Velo by Wix - what Velo is and what features it has.
Getting Started with Velo by Wix - step-by-step tutorial on how to start using Velo.
Onboarding to Velo by Wix - introduction to Velo with short tutorials.
Velo examples demonstrate how functionality works in a site and provide step-by-step instructions for building it. You can open an example as a template to see how page elements, code, and data work together, and use the template as the foundation for your next site.
If you find that you are having difficulty with code and need assistance, you may want to check out the Wix Marketplace - it’s a place where you can look for Velo experts for hire.