0
<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

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by New-Reign
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.