Hello. I’m trying to make a page where a user can input a 16 digit code and unlock whatever their code unlocked/purchased them through a button that pops up.
$w("#button2").hide()
$w("#button1").onClick(($w("#input1").value = ("the 16 digit code")){$w("#button2").show}
I realize my code is probably terrible, but I’m not used to Javascript.
Currently I’m confused on checking the input’s value and seeing if it matches with any string out of an array of strings, or even just one string… thanks!
You need something like this:
$w("#button1").onClick((event) => {
let value = $w("#input1").value;
if (value === "the 16 digit code") {
$w("#button2").show();
}
});
See the API documentation for the Button onClick() event handler, and for the Button show() function.
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 - has many examples demonstrating a wide variety of features and techniques. Filter by “Beginner” to get started.
Thank you for this, but it doesn’t seem to work… my current code:
$w("#button1").onClick((event) => {
let value = $w("#input1").value;
if (value === "16 Digit Code") {
$w("#button2").show();
$w("#text118").show();
}
});
Do you see an issue? I really wish Wix supported C#…
@michaeld Where do you have that code? In the page’s onReady()?
Better dont use the code, because other Visitors can see the codes in the code.
@yisrael-wix I have it under the main page code… Idk if that’s the page’s onReady or not
I thought of this but don’t know how to get around it.
@michaeld You are missing an onReady() on your page, and that is where your code should be. For more information about the page onReady() function, see the following: