|
-
Need Help with Decimal to binary converter
I want to develope a decimal to binary converter..
the js code is not working..plz help
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Status</title>
<script>
function myfunction() {
var x = document.getElementById("decimal").value;
var y = "";
while (x > 0) {
remainder = x % 2;
qoutient = Math.floor(x/2);
y = remainder + y;
x = qoutient;
}
document.getElementById("display").innerHTML = y;
}
</script>
</head>
<body>
<center>
<form id=convert onsubmit="myfunction()">
<input type="text" id=decimal>
<input type=submit value=Convert>
<p id="display">value</p>
</form>
</center>
</body>
</html>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|
Bookmarks