Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let sendButton = document.getElementById("send");
- let inputForm = document.getElementById("input");
- let selectMenuFrom = document.getElementById("selectMenuFrom");
- let selectMenuTo = document.getElementById("selectMenuTo");
- let resultOutputForm = document.getElementById("result");
- let optionElement = document.getElementsByTagName("option")[1];
- optionElement.value = "binary";
- optionElement.textContent = "Binary";
- let createOptionElement = document.createElement("option");
- createOptionElement.value = "hexadecimal";
- createOptionElement.textContent = "Hexadecimal";
- selectMenuTo.appendChild(createOptionElement);
- sendButton.addEventListener("click", function (){
- let inputFormValue = Number(inputForm.value);
- let valueOfForm = selectMenuTo.value;
- if (valueOfForm === "binary") {
- let numberToBinary = inputFormValue.toString(2);
- resultOutputForm.value = numberToBinary;
- } else if (valueOfForm === "hexadecimal"){
- let numberToHexadecimal = inputFormValue.toString(16);
- resultOutputForm.value = numberToHexadecimal.toUpperCase();
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement