input value example

This commit is contained in:
Jorijn van der Graaf 2025-11-12 16:36:52 +01:00
commit 3a45e25409
4 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,17 @@
import Crafter.CppDOM;
import std;
using namespace Crafter;
HtmlElement* body = new HtmlElement("body", R"(<h1>Input GetValue() and SetValue() Example</h1><br><input id="input" type="text" placeholder="Enter your text here..."><br><button id="button">Change Value</button><p id ="valueOutput"></p>)");
HtmlElement* button = new HtmlElement("button");
HtmlElement* output = new HtmlElement("valueOutput");
HtmlElement* input = new HtmlElement("input");
int main(){
button->AddClickListener([](Crafter::MouseEvent) {
std::string newValue = input->GetValue();
output->SetInnerHTML(newValue);
input->SetValue("");
});
}

View file

@ -0,0 +1,17 @@
{
"name": "main",
"configurations": [
{
"name": "executable",
"implementations": ["main"],
"target": "wasm32-wasi",
"debug" : true,
"dependencies": [
{
"path":"../../project.json",
"configuration":"lib-debug"
}
]
}
]
}

View file

@ -0,0 +1 @@
caddy file-server --listen :8080 --root bin/executable