<html>
<head>
<script>
"use strict";
function hexidecimal() {
var num = document.getElementsByName('number')[0].value;
var hex = num.toString(16);
alert(hex);
alert(num.toString(2));
}
</script>
</head>
<body>
<form id="form">
<input type="text" name="number" />
<input type="button" value="Hex" onClick="hexidecimal();" />
</form>
</body>
</html>
Above is the current code I have, I expect it to output the contents of whatever is held in the number input box as a hexidecimal number, instead it outputs whatever number is put into the box as base 1. Can anyone shed some light on what I have done wrong please?
Thanks