Pages

Wednesday, 4 December 2024

Text to Decimal Converter Tool



Text to Decimal Converter

Text to Decimal Converter

Converted Decimal Values:

/* Global styles */ body { font-family: 'Arial', sans-serif; background-color: #f0f8ff; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .container { background-color: #ffffff; border-radius: 10px; box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); padding: 30px; text-align: center; width: 60%; max-width: 600px; } h1 { font-size: 2.5em; color: #2c3e50; margin-bottom: 20px; } textarea { width: 80%; padding: 10px; font-size: 1em; border-radius: 5px; border: 2px solid #3498db; margin-bottom: 20px; resize: none; } button { background-color: #3498db; color: #fff; border: none; padding: 10px 20px; font-size: 1em; border-radius: 5px; cursor: pointer; } button:hover { background-color: #2980b9; } h2 { font-size: 1.8em; color: #2c3e50; margin-top: 20px; } .output-box { margin-top: 20px; padding: 10px; background-color: #ecf0f1; border: 1px solid #bdc3c7; font-size: 1.2em; color: #2c3e50; min-height: 40px; word-wrap: break-word; } function convertToDecimal() { // Get the input text value const text = document.getElementById("inputText").value; // Check if text is empty if (text.trim() === "") { document.getElementById("output").innerHTML = "Please enter some text to convert."; return; } // Convert each character to its ASCII decimal value const decimalValues = []; for (let i = 0; i < text.length; i++) { decimalValues.push(text.charCodeAt(i)); } // Display the decimal values as a string document.getElementById("output").innerHTML = decimalValues.join(' '); }