Skrypt skuter konwerter

Kolorwanie:
Status:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
<html>

    
<head>
    
<meta charset="utf-8">    
   
<script src="skrypt.js" type="text/javascript" async=""></script>
</head>


<body>
    
<b>Insert Decimal Number: </b><input type = "text" name = "deci" id = "deci" size = "15" maxlength = "15" />
<input type="button" value="Convert!" onclick="dec2bin()" />
<br><br>
<div id = "result"></div>

<script type = "text/javascript">

function dec2bin() {
var x = document.getElementById("deci").value;
if ((/[^0-9]/g.test(x)) || x == "") {
alert ("You must enter an integer decimal number!");
document.getElementById("deci").value = "";
document.getElementById("deci").focus();
return false;
}
x = parseInt(x);
var bin = x.toString(2);
var hex = x.toString(16).toUpperCase();
var octal = x.toString(8);


var figs = "The binary representation of " + x + " is " + bin + "<br>";
figs = figs + "The hexadecimal representation of " + x + " is " + hex + "<br>";
figs = figs + "The octal representation of " + x + " is " + octal + "<br>";

document.getElementById("result").innerHTML = figs;
}
</script>



    
</body>


</html>

Copyrights 2014-2019 © Wklejaj.pl Wszelkie prawa zastrzeżone.