0
No one knows how to convert decimal to binary using the stack in html
9 Answers
+ 18
<script>
function decToBin(x) {
return x.toString(2)
document.body.innerHTML = decToBin(5)
}
</script>
+ 17
var x = document.getElementById("num").value;
function convert() {
return x.toString(2)
}
+ 3
<input type="text" name="number" id="input">
<button onclick="convert()">Convert</button><br />
<span></span>
<script>
function convert(){
var x = $("#input").val();
x = x.length>0?Number(x).toString(2):'Please insert number';
$('span').text(x);
}
</script>
+ 2
just to state for better understanding, you cannot do any scripting in html, its strictly a hypertext markup language, as it acronym describes. The answers on how to accomplish this is correct, Javascript is the answer. just clarifying for your future reference, any calculations require another programming language
+ 1
yes but I do not know how to declaration
+ 1
thank you sir for your help ..... I'll give it a try
+ 1
I have created a body of html like this
<input type=text id=num>
<input type=button value='click' onclick='convert();'>
<input type=text id=result>
and I do not know how to declaration
+ 1
in the stack by using ... added element stack download stack elements and display elements of the stack
+ 1
ok sir....thank