The javascript is supposed to convert the input into base2 and display it in the output. I'm confused at why the output"o" is the the exact same as the input"num". I don't understand why this won't work. I know that the data is being passed correctly because if I put simple math in the function, then the output is fine. However, when I try to put the conversion in, it will not work.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>Base Converter</title>
<meta charset = "utf-8">
<script>
function Dec2Bin(val)
{
var num = val;
var n = num.toString(2);
convert.o.value = n;
}
</script>
</head>
<body>
<center>
<div class="banner"> <!--banner area-->
Convert from base 10 to base 2
</div>
<div class="body"> <!--function area-->
Please choose a number between 1 and 1,024
<form name="convert" class="alignment">
<input type="number" name="num">
<input type="button" value="Convert" onclick="Dec2Bin(num.value)">
<output name="o"></output>
</form>
</div>
</body>