Created
September 5, 2026 09:09
-
-
Save thinkphp/941dca2c5837e4be9a800181d29c63a3 to your computer and use it in GitHub Desktop.
Front end factorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script> | |
| function calculateFactorial() { | |
| const number = document.getElementById("number").value; | |
| fetch(`/factorial?number=${number}`) | |
| .then(response => response.json()) | |
| .then(data => { | |
| if(data.result) { | |
| document.getElementById("result").innerHTML = `Factorialul lui ${number} este ${data.result}` | |
| } else { | |
| document.getElementById("result").innerHTML = `Eroare: ${data.error}` | |
| } | |
| }) | |
| .catch(error => { | |
| document.getElementById("result").innerHTML = "Erorare la obtinera datelor" | |
| }) | |
| } | |
| </script> | |
| </head> | |
| <h1>Calcul Factorial</h1> | |
| <p>Introduceti un numar si apasati buttonul pentru a calcula factorialul acestuia </p> | |
| <input type="number" id="number" placeholder="Introduceti un nr"> | |
| <button onclick="calculateFactorial()">Calculeaza Factorialul</button> | |
| <div id="result"></div> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment