Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let options = document.getElementById("selectMenuTo");
- let binaryOption = document.createElement("option");
- binaryOption.textContent = "binary";
- options.appendChild(binaryOption);
- let hexOption = document.createElement("option");
- hexOption.textContent = "hexadecimal";
- options.appendChild(hexOption);
- function convert() {
- let input = Number(document.getElementById("input").value);
- let result;
- if (options.value.toLowerCase() === "binary") {
- result = input.toString(2);
- } else if (options.value.toLowerCase() === "hexadecimal") {
- result = input.toString(16).toUpperCase();
- }
- document.getElementById("result").value = result;
- }
- document.querySelector("#container > button").addEventListener('click', convert);
- }
Add Comment
Please, Sign In to add comment