Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <!-- attempts at javascript by lizette -->
- <title>Javascript test</title>
- <script type="text/javascript">
- function convert(){
- var num = document.getElementById("numberBox");
- var str = document.getElementById("stringBox");
- var x = 0;
- var y = "";
- x = parseInt(num.value);
- y = x.toString(2);
- if(y == "NaN"){
- y = "Not an integer.";
- }
- str.value = y;
- }
- </script>
- <style>
- #wrap{
- position: relative;
- }
- #content{
- margin: 0 auto;
- width: 300px;
- height: 100px;
- margin-top: 200px;
- font-family: Calibri, Arial;
- font-size: 12px;
- }
- h1{
- font-weight: normal;
- margin: 0;
- padding: 0;
- margin-bottom: 5px;
- font-size: 15px;
- }
- input{
- font-family: Calibri, Arial;
- font-size: 12px;
- width: 145px;
- }
- p{
- margin-left: 20px;
- }
- </style>
- </head>
- <body>
- <div id="wrap">
- <div id="content">
- <h1>Integer to Binary Converter</h1>
- <p>
- Input the integer on the left textbox. <br>
- Make sure that it really is an integer. <br>
- Doubles will be converted to its floor.
- </p>
- <input type="text" id="numberBox" value="0" onchange="convert()"> <input type="text" value="0" id="stringBox" readonly>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment