|
Tags: Blanking Manual revert |
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
| function storeInput() {
| |
| // Get the user's input
| |
| var userInput = prompt("Please enter your input:");
| |
|
| |
|
| // Set the #var with the user's input by embedding it back into the page
| |
| if (userInput !== null) {
| |
| var variableSyntax = '{{#vardefine: userInput | ' + userInput + '}}';
| |
|
| |
| // Update the HTML element to reflect the user's input
| |
| document.getElementById('display').innerHTML = variableSyntax;
| |
|
| |
| // To show what is stored
| |
| alert("Stored in #var: " + userInput);
| |
| }
| |
| }
| |
|
| |
| // Add the button dynamically to pages (if necessary)
| |
| document.addEventListener("DOMContentLoaded", function() {
| |
| var button = document.createElement("button");
| |
| button.textContent = "Enter Input";
| |
| button.onclick = storeInput;
| |
|
| |
| // Append the button to the body or a specific element
| |
| document.body.appendChild(button);
| |
| });
| |