Hi guys, I hope you can help me, please!
I’m trying to write a code that allows to disable an input field (switch, dropdown, text or button) if the user is NOT a client and at the same time enable the same input field if the user is already a client.
The only way to know if the user is a Client or not is referred into a database collection managed by the ADMIN only. This database collection is a private collection that only the admin can edit and access; the collection’s name is ‘ClientProfile’.
Then the user has 3 options:
a) If “(${Plan}).text” equals “Demo” then enable “switchDemo” and disable “switchBasic” and disable “switchPro”.
b) If “(${Plan}).text” is equal to “Basic” then enable “switchDemo” and “switchBasic” and disable “switchPro”
c) If “(${Plan}).text” is equal to “Pro” then enable the 3 switch / Demo / Basic and / Pro.
Using the functions “onClick” and / or “onChange” don’t work here because the client has already chosen his plan before. On this page, the client can complete the enable input fields that correspond directly to the plan that the client purchased. And they can see the disabled options and features of other available plans (to upgrade).
I tryed this code, with no success:
$w.onReady( function () {
let thePlan = $w(’ # textPlan’).text;
if (thePlan === ‘Demo’) {
$w(’ #switchDemo ‘).enable();
$w(’ #switchBasic ‘).disable();
$w(’ #switchPro ').disable(); }
if (thePlan === ‘Basic’) {
$w(’ #switchDemo ‘).enable();
$w(’ #switchBasic ‘).enable();
$w(’ #switchPro ').disable); }
if (thePlan === ‘Pro’) {
$w(’ #switchDemo ‘).enable();
$w(’ #switchBasic ‘).enable();
$w(’ #switchPro ').enable();
}
});
How would you do it? I look forward to your comments. I´ll really appreciate your help