0

No one knows how to convert decimal to binary using the stack in html

14th Mar 2017, 7:14 PM
yandi yandhi
yandi yandhi - avatar
9 Respostas
+ 18
<script> function decToBin(x) { return x.toString(2) document.body.innerHTML = decToBin(5) } </script>
14th Mar 2017, 8:31 PM
Gami
Gami - avatar
+ 17
var x = document.getElementById("num").value; function convert() { return x.toString(2) }
14th Mar 2017, 9:36 PM
Gami
Gami - avatar
+ 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>
14th Mar 2017, 9:33 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 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
14th Mar 2017, 9:31 PM
William La Flamme
William La Flamme - avatar
+ 1
yes but I do not know how to declaration
14th Mar 2017, 7:21 PM
yandi yandhi
yandi yandhi - avatar
+ 1
thank you sir for your help ..... I'll give it a try
14th Mar 2017, 7:27 PM
yandi yandhi
yandi yandhi - avatar
+ 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
14th Mar 2017, 8:48 PM
yandi yandhi
yandi yandhi - avatar
+ 1
in the stack by using ... added element stack download stack elements and display elements of the stack
14th Mar 2017, 8:51 PM
yandi yandhi
yandi yandhi - avatar
+ 1
ok sir....thank
14th Mar 2017, 9:37 PM
yandi yandhi
yandi yandhi - avatar