<!DOCTYPE html><html><head><title>Answer Display</title><script>function showAnswer() {var input = document.getElementById(&quot;inputField&quot;).value;var answer = input * 2; // Example function: doubling the inputdocument.getElementById(&quot;answerField&quot;).value = answer;} </script></head><body><h2>Answer Display</h2><label for="inputField">Enter a number:</label><input type="text" id="inputField" name="inputField"><br><br><button onclick="showAnswer()">Show Answer</button><br><br><label for="answerField">Answer:</label><input type="text" id="answerField" name="answerField" readonly><br><br></body></html>This code provides a text field where users can enter a number, a button labeled &quot;Show Answer&quot; that triggers the showAnswer() function, and an output field that displays the answer. The function retrieves the entered value, performs a calculation (in this case, doubling the input), and updates the output field accordingly.
HTML Text Field, Button, and Answer Display: A Simple Example

原文地址: https://www.cveoy.top/t/topic/pWa4 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录